Database: patch error handling to account for exceptions thrown by mysqli_query

This commit is contained in:
Aaron van Geffen 2024-08-27 11:46:18 +02:00
parent b64f87a49d
commit d6f39a3410

View File

@ -306,9 +306,11 @@ class Database
if (defined("DB_LOG_QUERIES") && DB_LOG_QUERIES) if (defined("DB_LOG_QUERIES") && DB_LOG_QUERIES)
$this->logged_queries[] = $db_string; $this->logged_queries[] = $db_string;
$return = @mysqli_query($this->connection, $db_string, empty($this->unbuffered) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT); try
{
if (!$return) $return = @mysqli_query($this->connection, $db_string, empty($this->unbuffered) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT);
}
catch (Exception $e)
{ {
$clean_sql = implode("\n", array_map('trim', explode("\n", $db_string))); $clean_sql = implode("\n", array_map('trim', explode("\n", $db_string)));
trigger_error($this->error() . '<br>' . $clean_sql, E_USER_ERROR); trigger_error($this->error() . '<br>' . $clean_sql, E_USER_ERROR);