Query time added to debug logfile
authorRoland Häder <roland@mxchange.org>
Sun, 31 Aug 2008 16:57:40 +0000 (16:57 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 31 Aug 2008 16:57:40 +0000 (16:57 +0000)
inc/db/lib-mysql3.php
inc/reset/reset_daily.php

index c35c234b1deef967fea965be3c2ffefb1f4031c4..b64e3937ec828ef647e2bec44dc6b9be87949201 100644 (file)
@@ -44,18 +44,27 @@ function SQL_QUERY($sql_string, $F, $L) {
        // Remove \t, \n and \r from queries they may confuse some MySQL version I have heard
        $sql_string = str_replace("\t", " ", str_replace("\n", " ", str_replace("\r", " ", $sql_string)));
 
        // Remove \t, \n and \r from queries they may confuse some MySQL version I have heard
        $sql_string = str_replace("\t", " ", str_replace("\n", " ", str_replace("\r", " ", $sql_string)));
 
+       // Starting time
+       $querytimeBefore = array_sum(explode(' ', microtime()));
+
        // Run SQL command
        $result = @mysql_query($sql_string, $link)
         or ADD_FATAL($F." (".$L."):".mysql_error()."<br />
 ".MYSQL_QUERY_STRING."<br />
 ".$sql_string);
 
        // Run SQL command
        $result = @mysql_query($sql_string, $link)
         or ADD_FATAL($F." (".$L."):".mysql_error()."<br />
 ".MYSQL_QUERY_STRING."<br />
 ".$sql_string);
 
-        // Count this query
-        if (!isset($_CONFIG['sql_count'])) $_CONFIG['sql_count'] = 0;
-        $_CONFIG['sql_count']++;
+       // Starting time
+       $querytimeAfter = array_sum(explode(' ', microtime()));
+
+       // Calculate query time
+       $queryTime = $querytimeAfter - $querytimeBefore;
+
+       // Count this query
+       if (!isset($_CONFIG['sql_count'])) $_CONFIG['sql_count'] = 0;
+       $_CONFIG['sql_count']++;
 
 
-        // Debug output
-        //* DEBUG: */ print "Query=<pre>".$sql_string."</pre>, affected=<b>".SQL_AFFECTEDROWS()."</b>, numrows=<b>".SQL_NUMROWS($result)."</b><br />\n";
+       // Debug output
+       //* DEBUG: */ print "Query=<pre>".$sql_string."</pre>, affected=<b>".SQL_AFFECTEDROWS()."</b>, numrows=<b>".SQL_NUMROWS($result)."</b><br />\n";
 
        if (($CSS != "1") && ($CSS != "-1") && (isBooleanConstantAndTrue('DEBUG_MODE')) && (DEBUG_SQL)) {
                //
 
        if (($CSS != "1") && ($CSS != "-1") && (isBooleanConstantAndTrue('DEBUG_MODE')) && (DEBUG_SQL)) {
                //
@@ -67,7 +76,7 @@ function SQL_QUERY($sql_string, $F, $L) {
                        fwrite($fp, "Module=".$GLOBALS['module']."\n");
                        $OK = true;
                }
                        fwrite($fp, "Module=".$GLOBALS['module']."\n");
                        $OK = true;
                }
-               fwrite($fp, $F."(LINE=".$L."|NUM=".SQL_NUMROWS($result)."|AFFECTED=".SQL_AFFECTEDROWS()."): ".str_replace('\r', "", str_replace('\n', " ", $sql_string))."\n");
+               fwrite($fp, $F."(LINE=".$L."|NUM=".SQL_NUMROWS($result)."|AFFECTED=".SQL_AFFECTEDROWS()."|QUERYTIME:".$queryTime."): ".str_replace('\r', "", str_replace('\n', " ", $sql_string))."\n");
                fclose($fp);
        }
 
                fclose($fp);
        }
 
index 9768fbb59c5f2352050da79315aef9ee01b5f72f..a02548c322d9085fb95677a19a52e50e93dd8933 100644 (file)
@@ -88,8 +88,10 @@ SQL_FREERESULT($result_daily);
 $_CONFIG['last_update'] = time();
 
 // Update database
 $_CONFIG['last_update'] = time();
 
 // Update database
-$result_daily = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config SET last_update=UNIX_TIMESTAMP()
-WHERE config=0 AND last_update != UNIX_TIMESTAMP() LIMIT 1", __FILE__, __LINE__);
+$result_daily = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_config
+SET last_update=UNIX_TIMESTAMP()
+WHERE config=0 AND last_update != UNIX_TIMESTAMP()
+LIMIT 1", __FILE__, __LINE__);
 
 // Destroy cache
 if ((GET_EXT_VERSION("cache") >= "0.1.2") && (SQL_AFFECTEDROWS() == 1))
 
 // Destroy cache
 if ((GET_EXT_VERSION("cache") >= "0.1.2") && (SQL_AFFECTEDROWS() == 1))