From 357b0491055e2dc7f0ad786042b05bd07764ebcf Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Tue, 26 Feb 2013 10:45:17 -0500
Subject: [PATCH] - Fixed bug with $mysqli->connect_error in PHP versions prior to 5.2.9 and 5.3.0.
---
interface/lib/classes/db_mysql.inc.php | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php
index 01eae1b..085eb54 100644
--- a/interface/lib/classes/db_mysql.inc.php
+++ b/interface/lib/classes/db_mysql.inc.php
@@ -60,7 +60,8 @@
$this->dbClientFlags = $conf[$prefix.'db_client_flags'];
parent::__construct($conf[$prefix.'db_host'], $conf[$prefix.'db_user'],$conf[$prefix.'db_password'],$conf[$prefix.'db_database']);
$try = 0;
- while(!is_null($this->connect_error) && $try < 5) {
+ //while(!is_null($this->connect_error) && $try < 5) {
+ while(mysqli_connect_error() && $try < 5) {
if($try > 0) sleep(1);
$try++;
@@ -69,7 +70,9 @@
parent::__construct($conf[$prefix.'db_host'], $conf[$prefix.'db_user'],$conf[$prefix.'db_password'],$conf[$prefix.'db_database']);
}
- if(is_null($this->connect_error)) $this->isConnected = true;
+ //if(is_null($this->connect_error)) $this->isConnected = true;
+ //else return false;
+ if(!mysqli_connect_error()) $this->isConnected = true;
else return false;
$this->setCharacterEncoding();
@@ -83,6 +86,7 @@
public function updateError($location) {
global $app;
+ /*
if(!is_null($this->connect_error)) {
$this->errorNumber = $this->connect_errno;
$this->errorMessage = $this->connect_error;
@@ -90,6 +94,15 @@
$this->errorNumber = $this->errno;
$this->errorMessage = $this->error;
}
+ */
+ if(mysqli_connect_error()) {
+ $this->errorNumber = mysqli_connect_errno();
+ $this->errorMessage = mysqli_connect_error();
+ } else {
+ $this->errorNumber = mysqli_errno($this);
+ $this->errorMessage = mysqli_error($this);
+ }
+
$this->errorLocation = $location;
if($this->errorNumber) {
--
Gitblit v1.9.1