mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add SQL_DEBUG variable and database logging
add a hook to db_query to log all sql queries when SQL_DEBUG is set Additionally, provide better logging for sql error situations (provide backtrace as well as error message). Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
10ea5f5ff6
commit
c43558ba60
2 changed files with 16 additions and 0 deletions
|
@ -238,10 +238,22 @@ function db_query($query="", $db_handle="") {
|
|||
if (!$query) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!$db_handle) {
|
||||
die("DB handle was not provided to db_query");
|
||||
}
|
||||
|
||||
if (SQL_DEBUG == 1) {
|
||||
$bt = debug_backtrace();
|
||||
error_log("DEBUG: ".$bt[0]['file'].":".$bt[0]['line']." query: $query\n");
|
||||
}
|
||||
|
||||
$result = @mysql_query($query, $db_handle);
|
||||
if (!$result) {
|
||||
$bt = debug_backtrace();
|
||||
error_log("ERROR: near ".$bt[0]['file'].":".$bt[0]['line']." in query: $query\n -> ".mysql_error($db_handle));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue