diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-02 14:45:41 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-02 14:45:41 +0100 |
commit | 4be5de1d11eefd9f0b7cf0589a2942f067cefe35 (patch) | |
tree | 6b360e221710377c2de0f3360e6c11a9ba1e9d6b /system/database/drivers/pdo | |
parent | bcb3bbb97c8c046f80009a2bd8dffb96795ed239 (diff) |
Replaced DB methods _error_message() and _error_number() with error() (issue #1097)
Diffstat (limited to 'system/database/drivers/pdo')
-rw-r--r-- | system/database/drivers/pdo/pdo_driver.php | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 90f0fd791..de5e1f05e 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -609,29 +609,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; } // -------------------------------------------------------------------- |