X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fdb%2Flib-mysql3.php;h=8dec70f75c3dec4c4917ce1a64870438b783cc57;hp=fc424e00289fab1c11706bc797793a26b238a0da;hb=14958a98e5119a7088b84e80e05908efa9bea760;hpb=4d6226782aa4ba157dca8c3891412ba50159481f
diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php
index fc424e0028..8dec70f75c 100644
--- a/inc/db/lib-mysql3.php
+++ b/inc/db/lib-mysql3.php
@@ -39,18 +39,22 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
}
// SQL queries
-function SQL_QUERY($sql_string, $F, $L, $compile=false)
+function SQL_QUERY($sql_string, $F, $L)
{
- global $link, $CSS, $CONFIG, $OK;
+ global $link, $CSS, $_CONFIG, $OK;
// Run SQL command
$result = @mysql_query($sql_string, $link)
- or ADD_FATAL($F." (".$L."):".mysql_error()."
-".MYSQL_QUERY_STRING."
+ 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']++;
+
// Debug output
- print "Query=".$sql_string.", affected=".SQL_AFFECTEDROWS().", numrows=".SQL_NUMROWS($result)."
\n";
+ //* DEBUG: */ print "Query=".$sql_string.", affected=".SQL_AFFECTEDROWS().", numrows=".SQL_NUMROWS($result)."
\n";
if (($CSS != "1") && ($CSS != "-1") && (DEBUG_MODE) && (DEBUG_SQL))
{
@@ -68,15 +72,15 @@ function SQL_QUERY($sql_string, $F, $L, $compile=false)
}
// Count DB hits
- if (!isset($CONFIG['db_hits']))
+ if (!isset($_CONFIG['db_hits']))
{
// Count in dummy variable
- $CONFIG['db_hits'] = 0;
+ $_CONFIG['db_hits'] = 0;
}
else
{
// Count to config array
- $CONFIG['db_hits']++;
+ $_CONFIG['db_hits']++;
}
return $result;
}
@@ -167,18 +171,21 @@ function SQL_CONNECT($host, $login, $password, $F, $L)
// SQL select database
function SQL_SELECT_DB($DB, $link, $F, $L)
{
- $DB = @mysql_select_db($DB, $link) or ADD_FATAL($F." (".$L."):".mysql_error());
- return $DB;
+ $select = false;
+ if (is_resource($link)) {
+ $select = @mysql_select_db($DB, $link) or ADD_FATAL($F." (".$L."):".mysql_error());
+ }
+ return $select;
}
// SQL close link
function SQL_CLOSE($link, $F, $L)
{
- global $CONFIG, $CACHE, $CFG_CACHE;
- if ((GET_EXT_VERSION("cache") >= "0.0.7") && (isset($CONFIG['db_hits'])) && (isset($CONFIG['cache_hits'])) && (is_object($CACHE)))
+ global $_CONFIG, $CACHE, $CFG_CACHE;
+ if ((GET_EXT_VERSION("cache") >= "0.0.7") && (isset($_CONFIG['db_hits'])) && (isset($_CONFIG['cache_hits'])) && (is_object($CACHE)))
{
// Update counter for db/cache
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET db_hits=%d, cache_hits=%d WHERE config='0' LIMIT 1",
- array(bigintval($CONFIG['db_hits']), bigintval($CONFIG['cache_hits'])), __FILE__, __LINE__);
+ array(bigintval($_CONFIG['db_hits']), bigintval($_CONFIG['cache_hits'])), __FILE__, __LINE__);
// Update cache here
if (GET_EXT_VERSION("cache") >= "0.1.2")
@@ -186,8 +193,8 @@ function SQL_CLOSE($link, $F, $L)
if ($CACHE->cache_file("config", true))
{
// Replace data
- $CACHE->cache_replace("cache_hits", $CONFIG['cache_hits'], "0", $CFG_CACHE);
- $CACHE->cache_replace("db_hits" , $CONFIG['db_hits'] , "0", $CFG_CACHE);
+ $CACHE->cache_replace("cache_hits", $_CONFIG['cache_hits'], "0", $CFG_CACHE);
+ $CACHE->cache_replace("db_hits" , $_CONFIG['db_hits'] , "0", $CFG_CACHE);
}
}
}