[evolvis-commits] r17957: better DB query tracing (after the release, always display errors)

mirabilos at evolvis.org mirabilos at evolvis.org
Mon Jan 9 10:41:44 CET 2012


Author: mirabilos
Date: 2012-01-09 10:41:44 +0100 (Mon, 09 Jan 2012)
New Revision: 17957

Modified:
   branches/QA-2011Q4:evolvis-qs.lan.tarent.de/src/common/include/database-pgsql.php
Log:
better DB query tracing (after the release, always display errors)


Modified: branches/QA-2011Q4:evolvis-qs.lan.tarent.de/src/common/include/database-pgsql.php
===================================================================
--- branches/QA-2011Q4:evolvis-qs.lan.tarent.de/src/common/include/database-pgsql.php	2012-01-09 09:41:36 UTC (rev 17956)
+++ branches/QA-2011Q4:evolvis-qs.lan.tarent.de/src/common/include/database-pgsql.php	2012-01-09 09:41:44 UTC (rev 17957)
@@ -173,12 +173,12 @@
 		$qstring=$qstring." LIMIT $limit OFFSET $offset";
 	}
 
+	$res = @pg_query($dbserver,$qstring);
 	if ($sysdebug_dbquery) {
-		ffDebug('trace', "tracing call of db_query():\n",
-		    debug_string_backtrace());
+		ffDebug('trace', "tracing " .
+		    ($res ? "successful" : sprintf("failed(%s)", db_error())) .
+		    " call of db_query():\n", debug_string_backtrace());
 	}
-
-	$res = @pg_query($dbserver,$qstring);
 	if (!$res) {
 		error_log('SQL: '. preg_replace('/\n\t+/', ' ',$qstring));
 		error_log('SQL> '.db_error());
@@ -254,13 +254,12 @@
 		$qstring=$qstring." LIMIT $limit OFFSET $offset";
 	}
 
+	$res = @pg_query_params($dbserver,$qstring,$params);
 	if ($sysdebug_dbquery) {
-		ffDebug('trace', "tracing call of db_query_params():\n",
-		    debug_string_backtrace());
-		error_log('SQL: '.db_query_to_string($qstring,$params).'; ');
+		ffDebug('trace', "tracing " .
+		    ($res ? "successful" : sprintf("failed(%s)", db_error())) .
+		    " call of db_query_params():\n", debug_string_backtrace());
 	}
-
-	$res = @pg_query_params($dbserver,$qstring,$params);
 	if (!$res) {
 		error_log('SQL: '. preg_replace('/\n\t+/', ' ',$qstring));
 		error_log('SQL> '.db_error($dbserver));



More information about the evolvis-commits mailing list