From ffd78f2dec0759e13e6a5b789b7b040c55fe5cc3 Mon Sep 17 00:00:00 2001 From: michaeljoseph Date: Fri, 20 Aug 2004 07:56:05 +0000 Subject: [PATCH] Added DEBUG SQL query logging. --- phplib/db_mysql.inc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/phplib/db_mysql.inc b/phplib/db_mysql.inc index 474efb5..19bbb1e 100755 --- a/phplib/db_mysql.inc +++ b/phplib/db_mysql.inc @@ -92,7 +92,15 @@ class DB_Sql { } /* public: perform a query */ - function query($Query_String) { + function query($Query_String) { + global $default; + // only log the queries if we're in debug mode + if ($default->minimumLoggingLevel == DEBUG) { + require_once("$default->fileSystemRoot/phpSniff/phpTimer.class.php"); + $timer = new phpTimer(); + $timer->start(); + } + /* No empty queries, please, since PHP4 chokes on them. */ if ($Query_String == "") /* The empty query string is passed on from the constructor, @@ -122,6 +130,13 @@ class DB_Sql { } # Will return nada if it fails. That's fine. + if ($default->minimumLoggingLevel == DEBUG) { + $timer->stop(); + if ($fp = fopen($default->fileSystemRoot . "/log/queryLog.txt", "a")) { + fwrite($fp, $timer->get_current() . ": $Query_String\n"); + } + fclose($fp); + } return $this->Query_ID; } -- libgit2 0.21.4