[ticket/10205] Rewrite _sql_error implementations to have a single return.

PHPBB3-10205
This commit is contained in:
Oleg Pudeyev 2012-12-04 21:32:02 -05:00
parent 89c9c9d4b0
commit 597dea1e04
5 changed files with 34 additions and 20 deletions

View file

@ -362,18 +362,20 @@ class dbal_mssql_odbc extends dbal
{
if (function_exists('odbc_errormsg'))
{
return array(
$error = array(
'message' => @odbc_errormsg(),
'code' => @odbc_error(),
);
}
else
{
return array(
$error = array(
'message' => $this->connect_error,
'code' => '',
);
}
return $error;
}
/**

View file

@ -539,18 +539,20 @@ class dbal_mssqlnative extends dbal
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
}
return array(
$error = array(
'message' => $error,
'code' => $code,
);
}
else
{
return array(
$error = array(
'message' => $this->connect_error,
'code' => '',
);
}
return $error;
}
/**

View file

@ -437,28 +437,32 @@ class dbal_mysql extends dbal
*/
function _sql_error()
{
if (!$this->db_connect_id)
if ($this->db_connect_id)
{
$error = array(
'message' => @mysql_error($this->db_connect_id),
'code' => @mysql_errno($this->db_connect_id),
);
}
else
{
if (function_exists('mysql_error'))
{
return array(
$error = array(
'message' => @mysql_error(),
'code' => @mysql_errno(),
);
}
else
{
return array(
$error = array(
'message' => $this->connect_error,
'code' => '',
);
}
}
return array(
'message' => @mysql_error($this->db_connect_id),
'code' => @mysql_errno($this->db_connect_id),
);
return $error;
}
/**

View file

@ -423,28 +423,32 @@ class dbal_mysqli extends dbal
*/
function _sql_error()
{
if (!$this->db_connect_id)
if ($this->db_connect_id)
{
$error = array(
'message' => @mysqli_error($this->db_connect_id),
'code' => @mysqli_errno($this->db_connect_id)
);
}
else
{
if (function_exists('mysqli_connect_error'))
{
return array(
$error = array(
'message' => @mysqli_connect_error(),
'code' => @mysqli_connect_errno(),
);
}
else
{
return array(
$error = array(
'message' => $this->connect_error,
'code' => '',
);
}
}
return array(
'message' => @mysqli_error($this->db_connect_id),
'code' => @mysqli_errno($this->db_connect_id)
);
return $error;
}
/**

View file

@ -302,18 +302,20 @@ class dbal_sqlite extends dbal
{
if (function_exists('sqlite_error_string'))
{
return array(
$error = array(
'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)),
'code' => @sqlite_last_error($this->db_connect_id),
);
}
else
{
return array(
$error = array(
'message' => $this->connect_error,
'code' => '',
);
}
return $error;
}
/**