Skip to content
Snippets Groups Projects
Commit de8e0783 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Database.php: In case of broken SQL queries, print them in ajax error message.

parent 781c09a5
No related branches found
No related tags found
No related merge requests found
...@@ -238,6 +238,7 @@ class Database { ...@@ -238,6 +238,7 @@ class Database {
$sqlLogMode = $this->isSqlModify($sql) ? SQL_LOG_MODE_MODIFY : SQL_LOG_MODE_ALL;; $sqlLogMode = $this->isSqlModify($sql) ? SQL_LOG_MODE_MODIFY : SQL_LOG_MODE_ALL;;
$result = 0; $result = 0;
$stat = array(); $stat = array();
$debugSql = '';
$this->store->setVar(SYSTEM_SQL_FINAL, $sql, STORE_SYSTEM); $this->store->setVar(SYSTEM_SQL_FINAL, $sql, STORE_SYSTEM);
$this->store->setVar(SYSTEM_SQL_PARAM_ARRAY, $parameterArray, STORE_SYSTEM); $this->store->setVar(SYSTEM_SQL_PARAM_ARRAY, $parameterArray, STORE_SYSTEM);
...@@ -245,18 +246,26 @@ class Database { ...@@ -245,18 +246,26 @@ class Database {
// Logfile // Logfile
$this->dbLog($sqlLogMode, $sql, $parameterArray); $this->dbLog($sqlLogMode, $sql, $parameterArray);
// If BE User is logged in: report the broken SQL as well.
//TODO: im Fall von delete.php, save.php, kann hier der BE_USER nicht abgefragt werden (laeuft nicht durch T3) - Loesung finden.
if (true) {
$debugSql = '[' . $sql . ']';
}
if (false === ($this->mysqli_stmt = $this->mysqli->prepare($sql))) { if (false === ($this->mysqli_stmt = $this->mysqli->prepare($sql))) {
throw new DbException('[ mysqli: ' . $this->mysqli->errno . ' ] ' . $this->mysqli->error, ERROR_DB_PREPARE); throw new DbException('[ mysqli: ' . $this->mysqli->errno . ' ] ' . $this->mysqli->error . $debugSql, ERROR_DB_PREPARE);
} }
if (count($parameterArray) > 0) { if (count($parameterArray) > 0) {
if (false === $this->prepareBindParam($parameterArray)) { if (false === $this->prepareBindParam($parameterArray)) {
throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error, ERROR_DB_BIND); throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error . $debugSql, ERROR_DB_BIND);
} }
} }
if (false === $this->mysqli_stmt->execute()) { if (false === $this->mysqli_stmt->execute()) {
throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error, ERROR_DB_EXECUTE); throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error . $debugSql, ERROR_DB_EXECUTE);
} }
$msg = ''; $msg = '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment