From 4209593d06a237995d8cc0ba527188a15cbd0376 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sun, 29 Mar 2009 11:13:59 -0700 Subject: [PATCH] CLEANUP: better debugging option for DB querries add option to only log querries that take a long time --- include/db.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/db.php b/include/db.php index da005a1..e389db4 100644 --- a/include/db.php +++ b/include/db.php @@ -59,16 +59,17 @@ function DB_test() function DB_query($query) { /* debug/optimize the database - $logfile=fopen('/tmp/DBlog.log','a+'); - fwrite($logfile,"EXPLAIN $query ;\n"); - $time = microtime(); $return = mysql_query($query); $time = $time - microtime(); - fwrite($logfile,"time of above query: $time\n"); - - fclose($logfile); + if($time > 0.05) // this way we can find only the long ones + { + $logfile=fopen('/tmp/DBlog.log','a+'); + fwrite($logfile,"EXPLAIN $query ;\n"); + fwrite($logfile,"time of above query: $time\n"); + fclose($logfile); + }; return $return; */ -- 2.25.1