]> git.mxchange.org Git - mailer.git/blobdiff - inc/db/lib-mysql3.php
Script rewritten to setConfigEntry(), getConfig() and incrementConfigEntry()
[mailer.git] / inc / db / lib-mysql3.php
index 0767c5f1628823eea4a731644b4cc9b306f0eae0..58bdc436b241c7b869fadfe1709d57d813c18dc1 100644 (file)
@@ -39,7 +39,7 @@ if (!defined('__SECURITY')) {
 
 // SQL queries
 function SQL_QUERY ($sql_string, $F, $L) {
-       global $link, $CSS, $_CONFIG, $OK;
+       global $link, $CSS, $OK;
 
        // Link is up?
        if (!is_resource($link)) return false;
@@ -50,6 +50,9 @@ function SQL_QUERY ($sql_string, $F, $L) {
        // Starting time
        $querytimeBefore = array_sum(explode(' ', microtime()));
 
+       // Replace {!_MYSQL_PREFIX!} with constant, closes #84. Thanks to profi-concept
+       $sql_string = str_replace("{!_MYSQL_PREFIX!}", constant('_MYSQL_PREFIX'), $sql_string);
+
        // Run SQL command
        //* DEBUG: */ echo $sql_string."<br />\n";
        $result = mysql_query($sql_string, $link)
@@ -64,7 +67,7 @@ Query string:<br />
        $queryTime = $querytimeAfter - $querytimeBefore;
 
        // Save last successfull query
-       $_CONFIG['db_last_query'] = $sql_string;
+       setConfigEntry('db_last_query', $sql_string);
 
        // Count this query
        incrementConfigEntry('sql_count');
@@ -89,10 +92,10 @@ Query string:<br />
        // Count DB hits
        if (getConfig('db_hits_run') == null) {
                // Count in dummy variable
-               $_CONFIG['db_hits_run'] = 1;
+               setConfigEntry('db_hits_run', 1);
        } else {
                // Count to config array
-               $_CONFIG['db_hits_run']++;
+               incrementConfigEntry('db_hits_run');
        }
 
        // Return the result
@@ -173,28 +176,26 @@ function SQL_FETCHARRAY($res, $nr=0, $remove_numerical=true) {
 }
 
 // SQL result
-function SQL_RESULT($res, $row, $field) {
+function SQL_RESULT ($res, $row, $field) {
        $result = mysql_result($res, $row, $field);
        return $result;
 }
 // SQL connect
-function SQL_CONNECT($host, $login, $password, $F, $L) {
+function SQL_CONNECT ($host, $login, $password, $F, $L) {
        $connect = mysql_connect($host, $login, $password) or addFatalMessage($F." (".$L."):".mysql_error());
        return $connect;
 }
 // SQL select database
-function SQL_SELECT_DB($dbName, $link, $F, $L) {
-       $select = false;
-       if (is_resource($link)) {
-               $select = mysql_select_db($dbName, $link) or addFatalMessage($F." (".$L."):".mysql_error());
-       }
-       return $select;
+function SQL_SELECT_DB ($dbName, $link, $F, $L) {
+       // Is there still a valid link? If not, skip it.
+       if (!is_resource($link)) return false;
+
+       return mysql_select_db($dbName, $link) or addFatalMessage($F." (".$L."):".mysql_error());
 }
 // SQL close link
-function SQL_CLOSE(&$link, $F, $L) {
-       global $_CONFIG, $cacheInstance, $cacheArray;
+function SQL_CLOSE (&$link, $F, $L) {
+       global $cacheInstance, $cacheArray;
 
-       // Is there still a valid link?
        if (!is_resource($link)) {
                // Skip double close
                return false;
@@ -204,7 +205,7 @@ function SQL_CLOSE(&$link, $F, $L) {
        //* DEBUG: */ echo "DB=".getConfig('db_hits').",CACHE=".getConfig('cache_hits')."<br />\n";
        if ((GET_EXT_VERSION("cache") >= "0.0.7") && (getConfig('db_hits') > 0) && (getConfig('cache_hits') > 0) && (is_object($cacheInstance))) {
                // Add new hits
-               $_CONFIG['db_hits'] += getConfig('db_hits_run');
+               incrementConfigEntry('db_hits', getConfig('db_hits_run'));
 
                // Update counter for db/cache
                UPDATE_CONFIG(array("db_hits", "cache_hits"), array(bigintval(getConfig('db_hits')), bigintval(getConfig('cache_hits'))));