changeset 81:e4e50d4d3b7a

DataAccess: Passage en mysqli
author Franck Deroche <franck@defr.org>
date Tue, 20 Nov 2018 00:53:47 +0100
parents b6ea01331de2
children 0a57d5321383
files includes/class.dataaccess.php
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/includes/class.dataaccess.php	Tue Nov 20 00:52:38 2018 +0100
+++ b/includes/class.dataaccess.php	Tue Nov 20 00:53:47 2018 +0100
@@ -18,6 +18,7 @@
    $this->db = $db;
    $this->connOpen = 0;
    $this->_nbQueries = 0;
+   $this->_inError = false;
    $this->queries = array();
    $this->results = array();
    $this->Connect();
@@ -25,11 +26,11 @@
  
   function Connect() {
    if($this->connOpen == 0) {
-     $this->link = mysql_connect($this->host, $this->user, $this->pass);
+     $this->link = mysqli_connect($this->host, $this->user, $this->pass, $this->db);
      if($this->link === false)
-     	$this->_inError = true;
+       $this->_inError = true;
      else
-     	$this->_inError = !mysql_select_db($this->db, $this->link);
+       mysqli_set_charset($this->link, 'utf8');
    }
    $this->connOpen++;
   }
@@ -38,9 +39,9 @@
    $this->_nbQueries++;
    $this->queries[$id]=$query;
    $this->Connect();
-   $this->results[$id]=mysql_query($this->queries[$id], $this->link);
+   $this->results[$id]=mysqli_query($this->link, $this->queries[$id]);
    $this->Close();
-   if(@$num_rows=mysql_num_rows($this->results[$id]))
+   if(@$num_rows=mysqli_num_rows($this->results[$id]))
 	return $num_rows;
    return 0;
   }
@@ -53,7 +54,7 @@
   }
   
   function GetRow($id=0) {
-   if(@$row=mysql_fetch_array($this->results[$id])) {
+   if(@$row=mysqli_fetch_array($this->results[$id])) {
     return $row;
    }
    return 0;    
@@ -62,7 +63,7 @@
   function Close() {
    $this->connOpen--;
    if($this->connOpen == 0) {
-    mysql_close($this->link);
+    mysqli_close($this->link);
    }
   }