From 7aa0dd55c0457e4f3edf79df2a20cd5ebc6d866d Mon Sep 17 00:00:00 2001 From: Alain Peyrat Date: Mon, 15 Mar 2010 21:26:46 +0000 Subject: [PATCH] Log SQL errors in the error to ease debugging. --- gforge/common/include/database-pgsql.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gforge/common/include/database-pgsql.php b/gforge/common/include/database-pgsql.php index f890006c4c..440924ce85 100644 --- a/gforge/common/include/database-pgsql.php +++ b/gforge/common/include/database-pgsql.php @@ -129,6 +129,10 @@ function db_query($qstring,$limit='-1',$offset=0,$dbserver=SYS_DB_PRIMARY) { //$GLOBALS['G_DEBUGQUERY'] .= $qstring .' |'.$dbserver.''. "

\n"; $res = @pg_query($dbserver,$qstring); + if (!$res) { + error_log('SQL: '. preg_replace('/\n\t+/', ' ',$qstring)); + error_log('SQL> '.db_error()); + } //echo "\n
|*| [$qstring]: ".db_error(); return $res; } @@ -161,6 +165,10 @@ function db_query_params($qstring,$params,$limit='-1',$offset=0,$dbserver=SYS_DB } $res = @pg_query_params($dbserver,$qstring,$params); + if (!$res) { + error_log('SQL: '. preg_replace('/\n\t+/', ' ',$qstring)); + error_log('SQL> '.db_error()); + } return $res; } -- 2.30.2