Skip to content

Commit

Permalink
more temp debug for SQL issues
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Jan 15, 2025
1 parent 6f72394 commit ad15d45
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions classes/Db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,26 @@ public function query($sql = "", $params = null) {
$pdoStatement->bindValue($paramKey, $paramValue, $paramType);
}

$ret = $pdoStatement->execute();
$pdoStatement->execute();

} else {
// Execute the raw query
$ret = $pdoStatement = $this->conn->query($sql);
$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));
ob_start();
$pdoStatement->debugDumpParams();
error_log(ob_get_clean());
error_log(print_r($pdoStatement->errorInfo(), true));
}

// Test the query actually worked
if (!$pdoStatement or !$ret) {
if (!$pdoStatement) {
$this->error($this->conn->errorCode() . ': ' . $this->conn->errorInfo()[2]);
ob_start();
$pdoStatement->debugDumpParams();
Expand All @@ -106,7 +110,7 @@ public function query($sql = "", $params = null) {
return;
}

if ((!$pdoStatement) or (empty($pdoStatement)) or (!$ret)) {
if ((!$pdoStatement) or (empty($pdoStatement))) {
// A failed query.
$this->success = false;

Expand Down

0 comments on commit ad15d45

Please sign in to comment.