-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.php
53 lines (38 loc) · 1.02 KB
/
database.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
# Um simples objeto
class Insere (
$ nome pública;
public $ addr;
$ cidade público;
$dsn = 'mysql:host=localhost;port=3306;dbname=bd';
$usuario = 'root';
$senha = 'joselito';
$opcoes = array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_CASE => PDO::CASE_LOWER
);
try {
$pdo = new PDO($dsn, $usuario, $senha, $opcoes);
} catch (PDOException $e) {
echo 'Erro: '.$e->getMessage();
}
STH = $ dbh-> ("INSERT INTO pessoas (nome, end, cidade) (valor: Nome: addr: cidade)");
bindParam $ sth-> (1, $ name);
bindParam $ sth-> (2, $ addr);
bindParam $ sth-> (3, $ cidade);
$ nome = "Daniel"
$ addr = "1 Wicked Way";
$ cidade = "Arlington Heights";
$ Sth-> execute ();
função __construct ($ n, $ a, $ c) (
$ This-> nome = $ n;
$ This-> end = $ a;
$ This-> $ cidade = c;
)
# Etc ...
)
?>