DB: fix handling failed query in debug_query method

This commit is contained in:
Benjamin Renard 2023-08-21 15:27:15 +02:00
parent d9451fd66a
commit 28e6397f58
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -85,6 +85,9 @@ class Db {
* @return void * @return void
*/ */
public static function debug_query($q) { public static function debug_query($q) {
$error = $q->getMessage();
// Execution time not available in case of execution error
if (!$error)
self :: $total_query_time += intval(ceil($q->getExecutionTime() * 1000000000)); self :: $total_query_time += intval(ceil($q->getExecutionTime() * 1000000000));
$msg = "# DB query"; $msg = "# DB query";
if ($q->getResult()) if ($q->getResult())
@ -104,6 +107,8 @@ class Db {
$msg .= "\n# Parameters: '" . vardump($parameters) . "'"; $msg .= "\n# Parameters: '" . vardump($parameters) . "'";
} }
} }
if ($error)
$msg .= "\n# ERROR: $error";
Log :: debug($msg); Log :: debug($msg);
} }