diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-03 02:52:16 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-03 02:52:16 +0100 |
commit | 8335a5db2a44b9272b066f524223b58904dd9f3f (patch) | |
tree | 688f1f0115c33bc65f40c5600e02f20b64d65537 /system/database/DB_driver.php | |
parent | 718d9ef22c4663f59f6f43c8945944f1f165c800 (diff) | |
parent | 8e89df8f92444eb02dc73b6c3e66077a4fb3f710 (diff) |
Merge upstream branch
Diffstat (limited to 'system/database/DB_driver.php')
-rw-r--r-- | system/database/DB_driver.php | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 5f435e363..b41a42051 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -222,36 +222,40 @@ class CI_DB_driver { // -------------------------------------------------------------------- /** - * Database Version Number. Returns a string containing the - * version of the database being used + * Database version number + * + * Returns a string containing the version of the database being used. + * Most drivers will override this method. * - * @access public * @return string */ - function version() + public function version() { - if (FALSE === ($sql = $this->_version())) + if (isset($this->data_cache['version'])) { - if ($this->db_debug) - { - return $this->display_error('db_unsupported_function'); - } - return FALSE; + return $this->data_cache['version']; } - // Some DBs have functions that return the version, and don't run special - // SQL queries per se. In these instances, just return the result. - $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo', 'mysqli'); - - if (in_array($this->dbdriver, $driver_version_exceptions)) - { - return $sql; - } - else + if (FALSE === ($sql = $this->_version())) { - $query = $this->query($sql); - return $query->row('ver'); + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; } + + $query = $this->query($sql); + $query = $query->row(); + return $this->data_cache['version'] = $query->ver; + } + + // -------------------------------------------------------------------- + + /** + * Version number query string + * + * @return string + */ + protected function _version() + { + return 'SELECT VERSION() AS ver'; } // -------------------------------------------------------------------- @@ -330,30 +334,28 @@ class CI_DB_driver { // This will trigger a rollback if transactions are being used $this->_trans_status = FALSE; - // Grab the error number and message now, as we might run some - // additional queries before displaying the error - $error_no = $this->_error_number(); - $error_msg = $this->_error_message(); + // Grab the error now, as we might run some additional queries before displaying the error + $error = $this->error(); // Log errors - log_message('error', 'Query error: '.$error_msg); + log_message('error', 'Query error: '.$error['message']); if ($this->db_debug) { // We call this function in order to roll-back queries - // if transactions are enabled. If we don't call this here + // if transactions are enabled. If we don't call this here // the error message will trigger an exit, causing the // transactions to remain in limbo. $this->trans_complete(); // Display errors return $this->display_error( - array( - 'Error Number: '.$error_no, - $error_msg, - $sql - ) - ); + array( + 'Error Number: '.$error['code'], + $error['message'], + $sql + ) + ); } return FALSE; |