summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2013-02-25 21:28:44 -0800
committerArun Persaud <arun@nubati.net>2013-02-25 21:28:44 -0800
commit14827e2adeee23e03a1223e237faf363b5ce0a3c (patch)
tree52f1c246656f42098350f3848f14028be9596706 /include
parent7a6c422d36beb00e0b6719fec7d3675b37d69af2 (diff)
downloade-DoKo-14827e2adeee23e03a1223e237faf363b5ce0a3c.tar.gz
e-DoKo-14827e2adeee23e03a1223e237faf363b5ce0a3c.tar.bz2
e-DoKo-14827e2adeee23e03a1223e237faf363b5ce0a3c.zip
better mysql-profiling output
Diffstat (limited to 'include')
-rw-r--r--include/db.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/include/db.php b/include/db.php
index 6568e75..91e5015 100644
--- a/include/db.php
+++ b/include/db.php
@@ -88,13 +88,21 @@ function DB_query($query)
/* debug/optimize the database
$time = microtime();
$return = $DB->query($query);
- $time = $time - microtime();
+ $time = microtime() - $time;
- if($time > 0.05) // this way we can find only the long ones
+ if($time > 0.15) // 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");
+ $logfile=fopen('DBlog.log','a+');
+ fwrite($logfile,"time of query: $time\n");
+ fwrite($logfile,wordwrap(" EXPLAIN $query ;\n", 60, "\n "));
+
+ $result = "";
+ $queryresult = mysql_query("EXPLAIN $query ;");
+ if( $queryresult )
+ while($row = DB_fetch_array($queryresult))
+ $result .= " |".implode("|",$row)."|\n";
+
+ fwrite($logfile,"$result \n\n");
fclose($logfile);
};