-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequetes.php
81 lines (70 loc) · 2.72 KB
/
requetes.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class DB {
private $db;
function __construct() {
$this->db = require 'connect.php';
}
public function get_patients() {
$query = $this->db->prepare('SELECT id, nom, prenom, secu, allergie, type, caracteristique, detachable, longueur, largeur
FROM patients');
$query->execute();
return $query->fetchAll();
}
public function get_one_patient($id) {
$query = $this->db->prepare('SELECT id, nom, prenom, secu, allergie, type, caracteristique, detachable, longueur, largeur
FROM patients
WHERE id = :id
LIMIT 1');
$query->execute([ ':id' => $id ]);
return $query->fetch();
}
public function add_one_patient($nom, $prenom, $secu, $allergie, $type, $caracteristique, $detachable, $longueur, $largeur) {
$query = $this->db->prepare('INSERT
INTO patients (nom, prenom, secu, allergie, type, caracteristique, detachable, longueur, largeur)
VALUES (:nom, :prenom, :secu, :allergie, :type, :caracteristique, :detachable, :longueur, :largeur)');
$query->execute([ ':nom' => $nom,
':prenom' => $prenom,
':secu' => $secu,
':allergie' => $allergie,
':type' => $type,
':caracteristique' => $caracteristique,
':detachable' => $detachable,
':longueur' => $longueur,
':largeur' => $largeur ]);
}
public function update_one_patient($id, $nom, $prenom, $secu, $allergie, $type, $caracteristique, $detachable, $longueur, $largeur) {
$query = $this->db->prepare('UPDATE patients
SET
nom = :nom,
prenom = :prenom,
secu = :secu,
allergie = :allergie,
type = :type,
caracteristique = :caracteristique,
detachable = :detachable,
longueur = :longueur,
largeur = :largeur
WHERE id = :id');
$query->execute([ ':id' => $id,
':nom' => $nom,
':prenom' => $prenom,
':secu' => $secu,
':allergie' => $allergie,
':type' => $type,
':caracteristique' => $caracteristique,
':detachable' => $detachable,
':longueur' => $longueur,
':largeur' => $largeur ]);
}
public function del_one_patient($id) {
$query = $this->db->prepare('DELETE
FROM patients
WHERE id = :id');
$query->execute([ ':id' => $id ]);
}
}