... | ... |
@@ -19,7 +19,7 @@ if( $scMoi->exist() && $scPartie->statut > 0 ) { |
19 | 19 |
* JOUEUR SORT DE LA SALLE D'ATTENTE |
20 | 20 |
*/ |
21 | 21 |
if( isset($_GET['out']) && $scMoi->exist() ) { |
22 |
- $db->req("UPDATE joueurs SET statut=0 WHERE id=".$scMoi->id.";"); |
|
22 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."joueurs SET statut=0 WHERE id=".$scMoi->id.";"); |
|
23 | 23 |
exit(); |
24 | 24 |
} |
25 | 25 |
|
... | ... |
@@ -56,11 +56,11 @@ if( isset($_GET['suppr']) ) { |
56 | 56 |
$suppr = intval($_GET['suppr']); |
57 | 57 |
|
58 | 58 |
if( $scPartie->exist() ) { |
59 |
- $db->req("DELETE FROM joueurs WHERE id=".$suppr." AND partie_id=".$scPartie->id.";"); |
|
59 |
+ $db->req("DELETE FROM ".$__CONF['dbtablepre']."joueurs WHERE id=".$suppr." AND partie_id=".$scPartie->id.";"); |
|
60 | 60 |
} |
61 | 61 |
else { |
62 |
- $db->req("DELETE FROM parties WHERE id=".$suppr.";"); |
|
63 |
- $db->req("DELETE FROM joueurs WHERE partie_id=".$suppr.";"); |
|
62 |
+ $db->req("DELETE FROM ".$__CONF['dbtablepre']."parties WHERE id=".$suppr.";"); |
|
63 |
+ $db->req("DELETE FROM ".$__CONF['dbtablepre']."joueurs WHERE partie_id=".$suppr.";"); |
|
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
exit(); |
... | ... |
@@ -71,7 +71,7 @@ if( isset($_GET['suppr']) ) { |
71 | 71 |
* ENTRER DANS LA SALLE D'ATTENTE |
72 | 72 |
*/ |
73 | 73 |
if( $scMoi->exist() && $scMoi->statut < 1 ) { |
74 |
- $db->req("UPDATE joueurs SET statut=1 WHERE id=".$scMoi->id.";"); |
|
74 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."joueurs SET statut=1 WHERE id=".$scMoi->id.";"); |
|
75 | 75 |
$scMoi->refresh(); |
76 | 76 |
} |
77 | 77 |
|
... | ... |
@@ -97,11 +97,11 @@ if( $scMoi->exist() ) |
97 | 97 |
echo '"liste":{'; |
98 | 98 |
|
99 | 99 |
if( $scMoi->exist() ) |
100 |
- $req = $db->req("SELECT id, nom FROM joueurs WHERE partie_id=".$scPartie->id." AND statut>0;"); |
|
100 |
+ $req = $db->req("SELECT id, nom FROM ".$__CONF['dbtablepre']."joueurs WHERE partie_id=".$scPartie->id." AND statut>0;"); |
|
101 | 101 |
elseif( $scPartie->exist() ) |
102 |
- $req = $db->req("SELECT id, nom FROM joueurs WHERE partie_id=".$scPartie->id.";"); |
|
102 |
+ $req = $db->req("SELECT id, nom FROM ".$__CONF['dbtablepre']."joueurs WHERE partie_id=".$scPartie->id.";"); |
|
103 | 103 |
else |
104 |
- $req = $db->req("SELECT id, nom FROM parties;"); |
|
104 |
+ $req = $db->req("SELECT id, nom FROM ".$__CONF['dbtablepre']."parties;"); |
|
105 | 105 |
|
106 | 106 |
$first = true; |
107 | 107 |
while($req1 = $db->next($req)) { |
... | ... |
@@ -1,31 +1,39 @@ |
1 | 1 |
<?php |
2 | 2 |
|
3 | 3 |
class Database { |
4 |
- private $_dbfile; |
|
5 | 4 |
private $_dbcnx; |
5 |
+ private $_req = false; |
|
6 | 6 |
|
7 |
- public function __construct($dbfile) { |
|
8 |
- $this->_dbfile = $dbfile; |
|
7 |
+ public function __construct($dbhost, $dbname, $dblogin, $dbpasswd) { |
|
8 |
+ $this->_dbcnx = new PDO('mysql:host='.$dbhost.';dbname='.$dbname.';charset=utf8', $dblogin, $dbpasswd); |
|
9 |
+ |
|
10 |
+/* |
|
9 | 11 |
$this->_dbcnx = false; |
10 | 12 |
while(!$this->_dbcnx) { |
11 | 13 |
$this->_dbcnx = new SQLite3($this->_dbfile); |
12 | 14 |
$this->_dbcnx->busyTimeout(5000); |
13 | 15 |
} |
16 |
+*/ |
|
14 | 17 |
} |
15 | 18 |
|
16 | 19 |
public function req($req) { |
17 |
- return $this->_dbcnx->query($req); |
|
20 |
+ if($this->_req) $this->_req->closeCursor(); |
|
21 |
+ $this->_req = $this->_dbcnx->query($req); |
|
22 |
+ return $this->_req; |
|
18 | 23 |
} |
19 | 24 |
|
20 | 25 |
public function next($dbreq) { |
21 |
- return $dbreq->fetchArray(); |
|
26 |
+ return $dbreq->fetch(); |
|
22 | 27 |
} |
23 | 28 |
|
24 | 29 |
public function reqFirst($req) { |
25 |
- return $this->next( $this->req( $req ) ); |
|
30 |
+ $dbreq = $this->req($req); |
|
31 |
+ if($dbreq) |
|
32 |
+ return $this->next( $dbreq ); |
|
33 |
+ return false; |
|
26 | 34 |
} |
27 | 35 |
} |
28 | 36 |
|
29 |
-$db = new Database($racine.'/'.$__CONF['dbfile']); |
|
37 |
+$db = new Database($__CONF['dbhost'], $__CONF['dbname'], $__CONF['dblogin'], $__CONF['dbpasswd']); |
|
30 | 38 |
|
31 | 39 |
?> |