-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.php
49 lines (40 loc) · 1.33 KB
/
test.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
<?php
use Database;
class UserModel{
public function save(string $email, string $password)
{
$sql = "INSERT INTO $this->table (email, password) VALUES (:email, :password)";
$query = $this->_connexion->prepare($sql);
$query->execute(
[
"email" => $email,
"password" => $password
]);
}
public function getAll(){
$sql= "SELECT * FROM ".$this->table;
return $this->execute_query($sql);
}
public function getOne(){
$sql= "SELECT * FROM ".$this->table." WHERE id=".$this->id;
return $this->execute_query($sql);
}
public function getAdd(){
$sql= "INSERT INTO ".$this->table."(`email`,`password`) values(".$this->email.",". $this->password.")";
return $this->execute_query($sql);
}
public function getEdit(){
$sql= "UPDATE ".$this->table." SET `email` =". $this->email.",`password` =". $this->password."WHERE id =".$this->id;
return $this->execute_query($sql);
}
public function getDelete(){
$sql= "DELETE FROM ".$this->table." WHERE id =".$this->id;
return $this->execute_query($sql);
}
private function execute_query($sql)
{
$query = $this->_connexion->prepare($sql);
$query->execute();
return $query->fetch();
}
}