// 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);
- // 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)) {
//
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);
}
$_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))