diff options
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/aur.inc | 12 | ||||
-rw-r--r-- | web/lib/config.inc.proto | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/web/lib/aur.inc b/web/lib/aur.inc index 66ae1c2b..5eed8e74 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -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; } diff --git a/web/lib/config.inc.proto b/web/lib/config.inc.proto index 80a7e540..43c64d22 100644 --- a/web/lib/config.inc.proto +++ b/web/lib/config.inc.proto @@ -20,6 +20,10 @@ define( "PASSWD_MAX_LEN", 128 ); # Default language for displayed messages in the web interface. define("DEFAULT_LANG", "en"); +# Enable debug sql output. This sends each query to error_log. Useful for +# development. Should not be enabled in production. Default to 0 (off). +define("SQL_DEBUG", 0); + # Languages we have translations for $SUPPORTED_LANGS = array( "ca" => "CatalĂ ", |