summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/sqlsrv/sqlsrv_driver.php
diff options
context:
space:
mode:
authorTimothy Warren <tim@timshomepage.net>2012-03-02 15:07:04 +0100
committerTimothy Warren <tim@timshomepage.net>2012-03-02 15:07:04 +0100
commitd33dab14c5d812d30f48d9a5f6324bb230e77203 (patch)
tree9f56e656e54c68d4a971b7985269f3c1cba1c696 /system/database/drivers/sqlsrv/sqlsrv_driver.php
parenteabc5ec81209ec83393222f2964098aedf6dbc7a (diff)
parent4be5de1d11eefd9f0b7cf0589a2942f067cefe35 (diff)
Merge upstream
Diffstat (limited to 'system/database/drivers/sqlsrv/sqlsrv_driver.php')
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php47
1 files changed, 20 insertions, 27 deletions
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 9b9038189..03d7c7199 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -406,46 +406,39 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * The error message string
+ * Error
*
- * @return string
+ * Returns an array containing code and message of the last
+ * database error that has occured.
+ *
+ * @return array
*/
- protected function _error_message()
+ public function error()
{
- $error = sqlsrv_errors();
- if ( ! is_array($error))
+ $error = array('code' => '00000', 'message' => '');
+ $sqlsrv_errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
+
+ if ( ! is_array($sqlsrv_errors))
{
- return '';
+ return $error;
}
- $error = array_shift($error);
- return isset($error['message']) ? $error['message'] : '';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
- *
- * @return string
- */
- protected function _error_number()
- {
- $error = sqlsrv_errors();
- if ( ! is_array($error))
+ $sqlsrv_error = array_shift($sqlsrv_errors);
+ if (isset($sqlsrv_error['SQLSTATE']))
{
- return '';
+ $error['code'] = isset($sqlsrv_error['code']) ? $sqlsrv_error['SQLSTATE'].'/'.$sqlsrv_error['code'] : $sqlsrv_error['SQLSTATE'];
}
- elseif (isset($error['SQLSTATE']))
+ elseif (isset($sqlsrv_error['code']))
{
- return isset($error['code']) ? $error['SQLSTATE'].'/'.$error['code'] : $error['SQLSTATE'];
+ $error['code'] = $sqlsrv_error['code'];
}
- elseif (isset($error['code']))
+
+ if (isset($sqlsrv_error['message']))
{
- return $error['code'];
+ $error['message'] = $sqlsrv_error['message'];
}
- return '';
+ return $error;
}
// --------------------------------------------------------------------