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