aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-12-04 16:12:31 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-12-04 16:12:31 -0500
commitde2fe1a308b08af868f22d6d9c0b7007f66de676 (patch)
tree386d3a62f159fb8b4a22f3f825e54ea3d02878a1 /phpBB
parent40db60e45f3d7af01a96f9da6b36db2606b3d147 (diff)
downloadforums-de2fe1a308b08af868f22d6d9c0b7007f66de676.tar
forums-de2fe1a308b08af868f22d6d9c0b7007f66de676.tar.gz
forums-de2fe1a308b08af868f22d6d9c0b7007f66de676.tar.bz2
forums-de2fe1a308b08af868f22d6d9c0b7007f66de676.tar.xz
forums-de2fe1a308b08af868f22d6d9c0b7007f66de676.zip
[ticket/10205] Convert mssqlnative driver to the same logic.
PHPBB3-10205
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/db/mssqlnative.php52
1 files changed, 32 insertions, 20 deletions
diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php
index 3ad0ff3e11..e5de30faf6 100644
--- a/phpBB/includes/db/mssqlnative.php
+++ b/phpBB/includes/db/mssqlnative.php
@@ -199,16 +199,18 @@ class dbal_mssqlnative extends dbal
var $m_insert_id = NULL;
var $last_query_text = '';
var $query_options = array();
+ var $connect_error = '';
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
- # Test for driver support, to avoid suppressed fatal error
+ // Test for driver support, to avoid suppressed fatal error
if (!function_exists('sqlsrv_connect'))
{
- trigger_error('Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx\n', E_USER_ERROR);
+ $this->connect_error = 'Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx';
+ return $this->sql_error('');
}
//set up connection variables
@@ -514,31 +516,41 @@ class dbal_mssqlnative extends dbal
*/
function _sql_error()
{
- $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS);
- $error_message = '';
- $code = 0;
-
- if ($errors != null)
+ if (function_exists('sqlsrv_errors'))
{
- foreach ($errors as $error)
+ $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS);
+ $error_message = '';
+ $code = 0;
+
+ if ($errors != null)
{
- $error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n";
- $error_message .= "code: ".$error[ 'code']."\n";
- $code = $error['code'];
- $error_message .= "message: ".$error[ 'message']."\n";
+ foreach ($errors as $error)
+ {
+ $error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n";
+ $error_message .= "code: ".$error[ 'code']."\n";
+ $code = $error['code'];
+ $error_message .= "message: ".$error[ 'message']."\n";
+ }
+ $this->last_error_result = $error_message;
+ $error = $this->last_error_result;
}
- $this->last_error_result = $error_message;
- $error = $this->last_error_result;
+ else
+ {
+ $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
+ }
+
+ return array(
+ 'message' => $error,
+ 'code' => $code,
+ );
}
else
{
- $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
+ return array(
+ 'message' => $this->connect_error,
+ 'code' => '',
+ );
}
-
- return array(
- 'message' => $error,
- 'code' => $code,
- );
}
/**