From 6f72394ff59e154f8fa8d05a8f0e39b55bfe9613 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 15 Jan 2025 11:39:43 +0000 Subject: [PATCH] temp error handling for debug --- classes/Db/Query.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/classes/Db/Query.php b/classes/Db/Query.php index 633e61185e..560ea8fed4 100644 --- a/classes/Db/Query.php +++ b/classes/Db/Query.php @@ -79,23 +79,34 @@ public function query($sql = "", $params = null) { $pdoStatement->bindValue($paramKey, $paramValue, $paramType); } - $pdoStatement->execute(); + $ret = $pdoStatement->execute(); } else { // Execute the raw query - $pdoStatement = $this->conn->query($sql); + $ret = $pdoStatement = $this->conn->query($sql); + } + + + $error = $pdoStatement->errorCode(); + if ($error and $error != "00000") { + error_log("Ruh Roh, $error"); + error_log(print_r($pdoStatement->errorInfo(), true)); } // Test the query actually worked - if (!$pdoStatement) { + if (!$pdoStatement or !$ret) { $this->error($this->conn->errorCode() . ': ' . $this->conn->errorInfo()[2]); + ob_start(); + $pdoStatement->debugDumpParams(); + error_log(ob_get_clean()); + error_log(print_r($pdoStatement->errorInfo(), true)); } if (!$this->success) { return; } - if ((!$pdoStatement) or (empty($pdoStatement))) { + if ((!$pdoStatement) or (empty($pdoStatement)) or (!$ret)) { // A failed query. $this->success = false;