diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-03 02:25:23 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-03 02:25:23 +0100 |
commit | 80e34f9cbd722193a5bdb94f4b593ae98c10efc7 (patch) | |
tree | 5d71422853b5d6ea1470b187fdfa1d042cab978a /system/database/DB_driver.php | |
parent | a92c7cdeddd9f1b46a6c8f254b2949ad047bbc21 (diff) | |
parent | 08856b8738ea4fc17b13986c9f2619383cb4a6e9 (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 73ec4e3ed..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', 'sqlite3', '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; |