diff options
author | Jamie Rumbelow <jamie@jamierumbelow.net> | 2012-03-06 22:27:46 +0100 |
---|---|---|
committer | Jamie Rumbelow <jamie@jamierumbelow.net> | 2012-03-06 22:27:46 +0100 |
commit | 3b1355c595127280d6d84d8b617a91fbeda319f5 (patch) | |
tree | 61e9d7c334e350846ffc3b528fbcbe85b036e1e9 /system/database/drivers/sqlsrv/sqlsrv_driver.php | |
parent | 576b47e9947d4f5bc25a3f72e3978a3d7f9ca1de (diff) | |
parent | 738f53448fecd1a27c7f89965fbfc47b3bafdb9b (diff) |
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
Conflicts:
system/database/DB_driver.php
system/database/DB_query_builder.php
Diffstat (limited to 'system/database/drivers/sqlsrv/sqlsrv_driver.php')
-rw-r--r-- | system/database/drivers/sqlsrv/sqlsrv_driver.php | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index d7095fa3f..6665b50aa 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -144,22 +144,6 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Set client character set - * - * @access public - * @param string - * @param string - * @return resource - */ - function db_set_charset($charset, $collation) - { - // @todo - add support if needed - return TRUE; - } - - // -------------------------------------------------------------------- - - /** * Execute the query * * @access private called by the base class @@ -333,15 +317,23 @@ class CI_DB_sqlsrv_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Version number query string - * - * @access public - * @return string - */ - function _version() + * Database version number + * + * @return string + */ + public function version() { - $info = sqlsrv_server_info($this->conn_id); - return sprintf("select '%s' as ver", $info['SQLServerVersion']); + if (isset($this->data_cache['version'])) + { + return $this->data_cache['version']; + } + + if (($info = sqlsrv_server_info($this->conn_id)) === FALSE) + { + return FALSE; + } + + return $this->data_cache['version'] = $info['SQLServerVersion']; } // -------------------------------------------------------------------- @@ -422,29 +414,39 @@ class CI_DB_sqlsrv_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_shift(sqlsrv_errors()); - return !empty($error['message']) ? $error['message'] : null; - } + $error = array('code' => '00000', 'message' => ''); + $sqlsrv_errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); - // -------------------------------------------------------------------- + if ( ! is_array($sqlsrv_errors)) + { + return $error; + } - /** - * The error message number - * - * @access private - * @return integer - */ - function _error_number() - { - $error = array_shift(sqlsrv_errors()); - return isset($error['SQLSTATE']) ? $error['SQLSTATE'] : null; + $sqlsrv_error = array_shift($sqlsrv_errors); + if (isset($sqlsrv_error['SQLSTATE'])) + { + $error['code'] = isset($sqlsrv_error['code']) ? $sqlsrv_error['SQLSTATE'].'/'.$sqlsrv_error['code'] : $sqlsrv_error['SQLSTATE']; + } + elseif (isset($sqlsrv_error['code'])) + { + $error['code'] = $sqlsrv_error['code']; + } + + if (isset($sqlsrv_error['message'])) + { + $error['message'] = $sqlsrv_error['message']; + } + + return $error; } // -------------------------------------------------------------------- |