1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00

[ticket/9521] Fix error reporting for the native SQL Server plugin.

The native SQL Server plugin used to return an error string when calling
sql_error. However, some error condition checks are done using is_array.
This patch wraps the error into an array to follow the error logic used
elsewhere.

PHPBB3-9521
This commit is contained in:
Henry Sudhof
2010-04-08 00:04:47 +02:00
committed by Andreas Fischer
parent 925a135613
commit 47557fd4d2

8
phpBB/includes/db/mssqlnative.php Normal file → Executable file
View File

@@ -502,6 +502,7 @@ class dbal_mssqlnative extends dbal
{ {
$errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS); $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS);
$error_message = ''; $error_message = '';
$code = 0;
if ($errors != null) if ($errors != null)
{ {
@@ -509,6 +510,7 @@ class dbal_mssqlnative extends dbal
{ {
$error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n"; $error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n";
$error_message .= "code: ".$error[ 'code']."\n"; $error_message .= "code: ".$error[ 'code']."\n";
$code = $error['code'];
$error_message .= "message: ".$error[ 'message']."\n"; $error_message .= "message: ".$error[ 'message']."\n";
} }
$this->last_error_result = $error_message; $this->last_error_result = $error_message;
@@ -518,7 +520,11 @@ class dbal_mssqlnative extends dbal
{ {
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
} }
return $error;
return array(
'message' => $error,
'code' => $code,
);
} }
/** /**