diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-05 15:17:32 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-05 15:17:32 +0100 |
commit | 99013ed3ed0ea5641a6c6b6afa08a7befb579cb0 (patch) | |
tree | ec85d2c3b418d87366d88f9efc96c03bfa839fdb /system/database/drivers/pdo/pdo_driver.php | |
parent | 62d6ee48b319dc7ec92b4a14fa8dbd3601060544 (diff) | |
parent | 57bdeb61bf199d1ae3ceaede4e9a9af8290ce715 (diff) |
Rename property _commit to commit_mode and merge upstream changes
Diffstat (limited to 'system/database/drivers/pdo/pdo_driver.php')
-rw-r--r-- | system/database/drivers/pdo/pdo_driver.php | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 90f0fd791..8fdfd58fb 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -289,13 +289,15 @@ class CI_DB_pdo_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string + * Database version number * * @return string */ - protected function _version() + public function version() { - return $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION); + return isset($this->data_cache['version']) + ? $this->data_cache['version'] + : $this->data_cache['version'] = $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION); } // -------------------------------------------------------------------- @@ -499,7 +501,7 @@ class CI_DB_pdo_driver extends CI_DB { */ public function insert_id($name = NULL) { - if ($this->pdodriver === 'pgsql' && $name === NULL && $this->_version() >= '8.1') + if ($this->pdodriver === 'pgsql' && $name === NULL && $this->version() >= '8.1') { $query = $this->query('SELECT LASTVAL() AS ins_id'); $query = $query->row(); @@ -609,29 +611,30 @@ class CI_DB_pdo_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @access private - * @return string + * Returns an array containing code and message of the last + * database error that has occured. + * + * @return array */ - function _error_message() + public function error() { - $error_array = $this->conn_id->errorInfo(); + $error = array('code' => '00000', 'message' => ''); + $pdo_error = $this->conn_id->errorInfo(); - return $error_array[2]; - } + if (empty($pdo_error[0])) + { + return $error; + } - // -------------------------------------------------------------------- + $error['code'] = isset($pdo_error[1]) ? $pdo_error[0].'/'.$pdo_error[1] : $pdo_error[0]; + if (isset($pdo_error[2])) + { + $error['message'] = $pdo_error[2]; + } - /** - * The error message number - * - * @access private - * @return integer - */ - function _error_number() - { - return $this->conn_id->errorCode(); + return $error; } // -------------------------------------------------------------------- |