// 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()));
-
// Replace {!_MYSQL_PREFIX!} with constant, closes #84. Thanks to profi-concept
$sql_string = str_replace("{!_MYSQL_PREFIX!}", constant('_MYSQL_PREFIX'), $sql_string);
+ // Starting time
+ $querytimeBefore = array_sum(explode(' ', microtime()));
+
// Run SQL command
//* DEBUG: */ echo $sql_string."<br />\n";
$result = mysql_query($sql_string, $link)
for ($idx = 0; $idx < ($max / 2); $idx++) {
// Remove entry
unset($row[$idx]);
- }
- }
+ } // END - for
+ } // END - if
// Return row
return $row;
$result = mysql_result($res, $row, $field);
return $result;
}
+
// SQL connect
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) {
// Is there still a valid link? If not, skip it.
return mysql_select_db($dbName, $link) or addFatalMessage($F." (".$L."):".mysql_error());
}
+
// SQL close link
function SQL_CLOSE (&$link, $F, $L) {
global $cacheInstance, $cacheArray;
} else {
$eval .= ", ''";
}
- }
+ } // END - foreach
$eval .= ");";
//
// Debugging
// Was the eval() command fine?
if ($query == "failed") {
// Something went wrong?
- printf("eval=%s\n<pre>%s</pre>",
- htmlentities($eval),
- debug_get_printable_backtrace()
- );
-
- // Abort further code executions
- exit;
+ debug_report_bug("eval={$eval}");
} // END - if
- if ($run) {
+ if ($run === true) {
// Run SQL query (default)
return SQL_QUERY($query, $file, $line);
} else {
} // END - if
if (!is_resource($link)) {
- // Fall-back to addslashes() when there is no link
- return addslashes($str);
- } // END - if
-
- if (function_exists('mysql_real_escape_string')) {
+ // Fall-back to smartAddSlashes() when there is no link
+ return smartAddSlashes($str);
+ } elseif (function_exists('mysql_real_escape_string')) {
// The new and improved version
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):str={$str}<br />\n";
return mysql_real_escape_string($str, $link);
// The obsolete function
return mysql_escape_string($str, $link);
} else {
- // If nothing else works
- return addslashes($str);
+ // If nothing else works, fall back to smartAddSlashes()
+ return smartAddSlashes($str);
}
}
$result = false;
// Determine index/fulltext/unique word
- $noIndex = ((eregi("INDEX", $sql) == false) && (eregi("FULLTEXT", $sql) == false) && (eregi("UNIQUE", $sql) == false);
+ // 12 3 3 2 2 3 3 2 2 3 3 21
+ $noIndex = ((eregi("INDEX", $sql) == false) && (eregi("FULLTEXT", $sql) == false) && (eregi("UNIQUE", $sql) == false));
// Shall we add/drop?
if (((eregi("ADD", $sql) > 0) || (eregi("DROP", $sql) > 0)) && ($noIndex)) {
// Return result
return $result;
}
+
//
?>