Commit ffd78f2dec0759e13e6a5b789b7b040c55fe5cc3
1 parent
f36ce8c1
Added DEBUG SQL query logging.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2919 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
16 additions
and
1 deletions
phplib/db_mysql.inc
| ... | ... | @@ -92,7 +92,15 @@ class DB_Sql { |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /* public: perform a query */ |
| 95 | - function query($Query_String) { | |
| 95 | + function query($Query_String) { | |
| 96 | + global $default; | |
| 97 | + // only log the queries if we're in debug mode | |
| 98 | + if ($default->minimumLoggingLevel == DEBUG) { | |
| 99 | + require_once("$default->fileSystemRoot/phpSniff/phpTimer.class.php"); | |
| 100 | + $timer = new phpTimer(); | |
| 101 | + $timer->start(); | |
| 102 | + } | |
| 103 | + | |
| 96 | 104 | /* No empty queries, please, since PHP4 chokes on them. */ |
| 97 | 105 | if ($Query_String == "") |
| 98 | 106 | /* The empty query string is passed on from the constructor, |
| ... | ... | @@ -122,6 +130,13 @@ class DB_Sql { |
| 122 | 130 | } |
| 123 | 131 | |
| 124 | 132 | # Will return nada if it fails. That's fine. |
| 133 | + if ($default->minimumLoggingLevel == DEBUG) { | |
| 134 | + $timer->stop(); | |
| 135 | + if ($fp = fopen($default->fileSystemRoot . "/log/queryLog.txt", "a")) { | |
| 136 | + fwrite($fp, $timer->get_current() . ": $Query_String\n"); | |
| 137 | + } | |
| 138 | + fclose($fp); | |
| 139 | + } | |
| 125 | 140 | return $this->Query_ID; |
| 126 | 141 | } |
| 127 | 142 | ... | ... |