Log SQL warnings to the error log, but only in development

pull/51/head
Starbeamrainbowlabs 3 years ago
parent e86b0b4f97
commit 74b1b212fe
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
  1. 6
      logic/Database.php

@ -88,6 +88,12 @@ class Database
// FUTURE: Optionally cache prepared statements?
$statement = $this->connection->prepare($sql);
$statement->execute($variables);
if($this->settings->get("env.mode") == "development") {
$warnings = $this->connection->query("SHOW WARNINGS;")->fetchAll();
error_log("Warnings: " . var_export($warnings, true));
}
return $statement; // fetchColumn(), fetchAll(), etc. are defined on the statement, not the return value of execute()
}

Loading…
Cancel
Save