forked from halo-battle/game
Migrate to mysqli PHP extension
This commit is contained in:
parent
1bcad3d120
commit
162dd444bd
@ -7,7 +7,7 @@ switch($OPT['type'])
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
|
||||
$api = array('mysql' => 'mysql_connect', 'postgresql' => 'pg_connect');
|
||||
$api = array('mysql' => 'mysqli_connect', 'postgresql' => 'pg_connect');
|
||||
if(!function_exists($api[$OPT['type']])) trigger_error('API introuvable',E_USER_ERROR);
|
||||
unset($api);
|
||||
|
||||
|
@ -56,7 +56,7 @@ class BDD
|
||||
|
||||
$this->reponse = NULL;
|
||||
|
||||
$this->session = mysql_connect($host,$user,$pass);
|
||||
$this->session = mysqli_connect($host,$user,$pass);
|
||||
|
||||
if(!$this->session)
|
||||
{
|
||||
@ -65,7 +65,7 @@ class BDD
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mysql_query('SET CHARACTER SET "utf8"',$this->session);
|
||||
mysqli_query($this->session,'SET CHARACTER SET "utf8"');
|
||||
|
||||
$this->host = $host;
|
||||
$this->user = $user;
|
||||
@ -77,14 +77,14 @@ class BDD
|
||||
|
||||
function reconnexion()
|
||||
{
|
||||
if(!empty($this->host) && !empty($this->user) && isset($this->password) && !empty($this->database)) $this->connexion($this->host,$this->user,$this->password,$this->database);
|
||||
if(!empty($this->host) && !empty($this->user) && !empty($this->password) && !empty($this->database)) $this->connexion($this->host,$this->user,$this->password,$this->database);
|
||||
}
|
||||
|
||||
function deconnexion()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$r = mysql_close($this->session);
|
||||
$r = mysqli_close($this->session);
|
||||
$this->session = FALSE;
|
||||
$this->connected = FALSE;
|
||||
return $r;
|
||||
@ -94,20 +94,20 @@ class BDD
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return mysql_error($this->session);
|
||||
return mysqli_error($this->session);
|
||||
}
|
||||
|
||||
function db($db=NULL)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return $this->database = mysql_select_db($db,$this->session) ? $db : $this->database;
|
||||
return $this->database = mysqli_select_db($this->session,$db) ? $db : $this->database;
|
||||
}
|
||||
|
||||
function escape(&$var)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
$var = mysql_real_escape_string($var,$this->session);
|
||||
$var = mysqli_real_escape_string($this->session,$var);
|
||||
return $var;
|
||||
}
|
||||
|
||||
@ -115,19 +115,19 @@ class BDD
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$this->reponse = mysql_query($query,$this->session);
|
||||
$this->reponse = mysqli_query($this->session,$query);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(!$this->reponse && $db_config['log']) elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
|
||||
|
||||
$this->num_rows = @mysql_num_rows($this->reponse);
|
||||
$this->num_rows = @mysqli_num_rows($this->reponse);
|
||||
|
||||
if($this->num_rows == 0) return NULL;
|
||||
|
||||
elseif($this->num_rows >= 1)
|
||||
{
|
||||
for($i=0; $var = mysql_fetch_assoc($this->reponse); $i++) $sortie[$i] = $var;
|
||||
for($i=0; $var = mysqli_fetch_assoc($this->reponse); $i++) $sortie[$i] = $var;
|
||||
return $sortie;
|
||||
}
|
||||
|
||||
@ -138,17 +138,17 @@ class BDD
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$this->reponse = mysql_query($query,$this->session);
|
||||
$this->reponse = mysqli_query($this->session,$query);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(!$this->reponse && $db_config['log']) elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
|
||||
|
||||
$this->num_rows = @mysql_num_rows($this->reponse);
|
||||
$this->num_rows = @mysqli_num_rows($this->reponse);
|
||||
|
||||
if($this->num_rows == 0) return NULL;
|
||||
|
||||
elseif($this->num_rows >= 1) return mysql_fetch_assoc($this->reponse);
|
||||
elseif($this->num_rows >= 1) return mysqli_fetch_assoc($this->reponse);
|
||||
|
||||
else return FALSE;
|
||||
}
|
||||
@ -157,7 +157,7 @@ class BDD
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return mysql_affected_rows($this->session);
|
||||
return mysqli_affected_rows($this->session);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user