changeset 68:0071e5744311

Ajout d'un m├ęcanisme de detection des erreurs.
author Franck Deroche <webmaster@defr.org>
date Wed, 19 Mar 2008 12:02:43 +0100
parents 251a4c4e05d1
children d67a65183100
files includes/class.dataaccess.php
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/includes/class.dataaccess.php	Tue Mar 18 18:47:19 2008 +0100
+++ b/includes/class.dataaccess.php	Wed Mar 19 12:02:43 2008 +0100
@@ -9,6 +9,7 @@
   var $results;
   var $queries;
   var $_nbQueries;
+  var $_inError;
   
   function DataAccess($host=DB_HOST, $user=DB_USER, $pass=DB_PASSWORD, $db=DB_NAME) {
    $this->host=$host;
@@ -25,7 +26,10 @@
   function Connect() {
    if($this->connOpen == 0) {
      $this->link = mysql_connect($this->host, $this->user, $this->pass);
-     mysql_select_db($this->db, $this->link);
+     if($this->link === false)
+     	$this->_inError = true;
+     else
+     	$this->_inError = !mysql_select_db($this->db, $this->link);
    }
    $this->connOpen++;
   }
@@ -69,5 +73,10 @@
   function formatDate($timestamp, $decallage=2, $pattern='d/m/Y H:i:s') {
    return gmdate($pattern, $timestamp + $decallage * 3600);
   }
+  
+  function isInError()
+  {
+    return $this->_inError;
+  }
 }
 ?>