-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconnect.php
executable file
·60 lines (50 loc) · 1.68 KB
/
connect.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
<?php
require('phpagi/phpagi.php');
class connect_bdd{
protected function dbconnect(){
$bdd = new PDO('mysql:host=localhost;dbname=Asterisk','server','server') or die ('Not connected');
return $bdd;
}
}
class Query_bdd extends connect_bdd{
public function consolde($num){
$bdd = $this->dbconnect();
$consulter = $bdd->query( "SELECT Solde FROM Utilisateurs where Numero = '$num' ");
$sld = $consulter->fetchall();
return $sld[0][0];
}
public function transaction($idexp, $iddest, $montant){
$bdd = $this->dbconnect();
$res = $bdd->prepare("INSERT INTO Transactions(Daty, Num_Exp, Num_Dest, Somme) values( NOW(), ?, ?, ?)");
$res->execute(array($idexp, $iddest, $montant));
}
public function isUser($num){
$bdd = $this->dbconnect();
$res = $bdd->prepare("SELECT 1 FROM Utilisateurs WHERE Numero = ? ");
$res->execute(array($num));
if ($res->rowCount()==1){
return true ;
}
return false;
}
public function moins($idexp, $montant){
$bdd = $this->dbconnect();
$res = $bdd->prepare("UPDATE Utilisateurs SET Solde = (Solde - ?) WHERE Numero = ?");
$res->execute(array($montant, $idexp));
}
public function plus($iddest, $montant){
$bdd = $this->dbconnect();
$res = $bdd->prepare("UPDATE Utilisateurs SET Solde = (Solde + ?) WHERE Numero = ?");
$res->execute(array($montant, $iddest));
}
public function login($num, $pass){
$bdd = $this->dbconnect();
$res = $bdd->prepare("SELECT 1 FROM Utilisateurs WHERE Numero=? AND Password=?");
$res->execute(array($num, $pass));
if ($res->rowCount() == 1){
return true;
}
return false;
}
}
?>