1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-25 12:35:55 +02:00

[ticket/10205] Convert mssqlnative driver to the same logic.

PHPBB3-10205
This commit is contained in:
Oleg Pudeyev
2012-12-04 16:12:31 -05:00
parent 40db60e45f
commit de2fe1a308

View File

@ -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,
);
}
/**