-
Notifications
You must be signed in to change notification settings - Fork 3
/
DB.php
59 lines (49 loc) · 1.48 KB
/
DB.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
54
55
56
57
58
59
<?php
require_once 'conexion/DB_Connect.php';
require_once 'modelo/Usuarios.php';
class DB
{
private $db;
private $pdo;
function __construct()
{
$this->db = new DB_Connect();
$this->pdo = $this->db->connect();
}
function __destruct() { }
public function getAllUsuarios()
{
$stmt = $this->pdo->prepare('SELECT * FROM people');
$stmt->execute();
$array = array();
$ind = 0;
foreach ($stmt as $row)
{
// do something with $row
$itm = new Usuarios(); //obtenemos los campos del models
$itm->id= $row['id'];
$itm->nombre = $row['name'];
$array[$ind] = $itm;
$ind++;
}
return $array;
}
public function getUsuario($id)
{
$stmt = $this->pdo->prepare('SELECT * from people where id = :id ');
$stmt->execute( array('id' => $id));
$array = array();
$ind = 0;
foreach ($stmt as $row)
{
// do something with $row
$itm = new Usuarios(); //obtenemos los campos del models/Tipo_lesiones
$itm->id= $row['id'];
$itm->nombre = $row['name'];
$array[$ind] = $itm;
$ind++;
}
return $array;
}
}
?>