From 5ffce605017a2a3d90794baf1fd0eb6f1eb28c83 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Apr 2005 02:03:19 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Gestion=20d'erreur=20sur=20l'=E9chec=20d?= =?UTF-8?q?e=20connexion=20base?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/lib/mysql.lib.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/htdocs/lib/mysql.lib.php b/htdocs/lib/mysql.lib.php index b03ee0c378c..023e1c47da6 100644 --- a/htdocs/lib/mysql.lib.php +++ b/htdocs/lib/mysql.lib.php @@ -465,10 +465,17 @@ class DoliDb function errno() { - if (isset($this->errorcode_map[mysql_errno($this->db)])) { - return $this->errorcode_map[mysql_errno($this->db)]; + if (! $this->connected) { + // Si il y a eu echec de connection, $this->db n'est pas valide. + return 'DB_ERROR_FAILED_TO_CONNECT'; + } + else { + // Si il y a eu echec de connection, $this->db n'est pas valide. + if (isset($this->errorcode_map[mysql_errno($this->db)])) { + return $this->errorcode_map[mysql_errno($this->db)]; + } + return 'DB_ERROR_'.mysql_errno($this->db); } - return 'DB_ERROR_'.mysql_errno($this->db); } /** @@ -478,7 +485,13 @@ class DoliDb function error() { - return mysql_error($this->db); + if (! $this->connected) { + // Si il y a eu echec de connection, $this->db n'est pas valide pour mysql_error. + return 'Not connected. Check setup parameters in conf/conf.php file'; + } + else { + return mysql_error($this->db); + } } /**