diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-11-05 16:01:11 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-11-05 16:01:11 +0100 |
commit | 2b73037e450859e85fb468ad7499a26882a67292 (patch) | |
tree | 8388444fba44c5188c8977949d4a931320cd3e05 /system/database/drivers/mysql/mysql_driver.php | |
parent | 522c73623b46afc9082ac7c8af5c34bf1b4f47f4 (diff) |
Fix DB drivers version() implementations that don't execute a query
Fails if called prior to the DB connection initialization.
Diffstat (limited to 'system/database/drivers/mysql/mysql_driver.php')
-rw-r--r-- | system/database/drivers/mysql/mysql_driver.php | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 2457e558c..b1edc2925 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -191,9 +191,21 @@ class CI_DB_mysql_driver extends CI_DB { */ public function version() { - return isset($this->data_cache['version']) - ? $this->data_cache['version'] - : $this->data_cache['version'] = @mysql_get_server_info($this->conn_id); + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + elseif ( ! $this->conn_id) + { + $this->initialize(); + } + + if ( ! $this->conn_id OR ($version = @mysql_get_server_info($this->conn_id)) === FALSE) + { + return FALSE; + } + + return $this->data_cache['version'] = $version; } // -------------------------------------------------------------------- |