From 114d6b94e8c2aa1ec5c79465fb2011196ec6f70b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 31 Aug 2008 16:57:40 +0000 Subject: [PATCH 1/1] Query time added to debug logfile --- inc/db/lib-mysql3.php | 21 +++++++++++++++------ inc/reset/reset_daily.php | 6 ++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index c35c234b1d..b64e3937ec 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -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))); + // Starting time + $querytimeBefore = array_sum(explode(' ', microtime())); + // Run SQL command $result = @mysql_query($sql_string, $link) or ADD_FATAL($F." (".$L."):".mysql_error()."
".MYSQL_QUERY_STRING."
".$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=
".$sql_string."
, affected=".SQL_AFFECTEDROWS().", numrows=".SQL_NUMROWS($result)."
\n"; + // Debug output + //* DEBUG: */ print "Query=
".$sql_string."
, affected=".SQL_AFFECTEDROWS().", numrows=".SQL_NUMROWS($result)."
\n"; 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, $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); } diff --git a/inc/reset/reset_daily.php b/inc/reset/reset_daily.php index 9768fbb59c..a02548c322 100644 --- a/inc/reset/reset_daily.php +++ b/inc/reset/reset_daily.php @@ -88,8 +88,10 @@ SQL_FREERESULT($result_daily); $_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)) -- 2.39.2