From dbad54e09a39a77c7404dee9ca1a6b34299469d0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 21:53:32 +0300 Subject: Fix issue #1765 --- system/database/drivers/mysqli/mysqli_driver.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 453ddcc3f..14949ecda 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -66,8 +66,8 @@ class CI_DB_mysqli_driver extends CI_DB { { $port = empty($this->port) ? NULL : $this->port; - $mysqli = mysqli_init(); - $mysqli->real_connect($this->hostname, $this->username, $this->password, $this->database, $port, NULL, MYSQLI_CLIENT_COMPRESS); + $mysqli = new mysqli(); + @$mysqli->real_connect($this->hostname, $this->username, $this->password, $this->database, $port, NULL, MYSQLI_CLIENT_COMPRESS); return $mysqli; } @@ -418,6 +418,14 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function error() { + if ( ! empty($this->conn_id->connect_errno)) + { + return array( + 'code' => $this->conn_id->connect_errno, + 'message' => is_php('5.2.9') ? $this->conn_id->connect_error : mysqli_connect_error() + ); + } + return array('code' => $this->conn_id->errno, 'message' => $this->conn_id->error); } -- cgit v1.2.3-24-g4f1b