$querytimeBefore = array_sum(explode(' ', microtime()));
// Run SQL command
- //* DEBUG: */ outputHtml($sqlString."<br />");
+ //* DEBUG: */ print($sqlString . '<br />');
$result = mysql_query($sqlString, SQL_GET_LINK())
or addFatalMessage(__FUNCTION__, __LINE__, $F . ' (' . $L . '):' . mysql_error() . '<br />
Query string:<br />
' . $sqlString);
- //* DEBUG: */ outputHtml(__LINE__ . ': numRows=' . SQL_NUMROWS($result) . ',affected=' . SQL_AFFECTEDROWS() . "<br />");
+ //* DEBUG: */ print(__LINE__ . ': numRows=' . SQL_NUMROWS($result) . ',affected=' . SQL_AFFECTEDROWS() . "<br />");
// Ending time
$querytimeAfter = array_sum(explode(' ', microtime()));
incrementConfigEntry('sql_count');
// Debug output
- if ((getOutputMode() != '1') && (isDebugModeEnabled()) && (getConfig('DEBUG_SQL') == 'Y')) {
+ if ((getOutputMode() != 1) && (isDebugModeEnabled()) && (isConfigEntrySet('DEBUG_SQL')) && (getConfig('DEBUG_SQL') == 'Y')) {
//
// Debugging stuff...
//
} // END - if
// Count DB hits
- if (!isStatsEntrySet('db_hits_run')) {
+ if (!isStatsEntrySet('db_hits')) {
// Count in dummy variable
- setStatsEntry('db_hits_run', 1);
+ setStatsEntry('db_hits', 1);
} else {
// Count to config array
- incrementStatsEntry('db_hits_run');
+ incrementStatsEntry('db_hits');
}
// Return the result
// Destroy cache
unset($GLOBALS['sql_link_res']);
- // Move stats
- incrementStatsEntry('db_hits', getStatsEntry('db_hits_run'));
-
// Return the result
return $close;
}
// Escape a string for the database
function SQL_ESCAPE ($str, $secureString=true, $strip=true) {
// Do we have cache?
- if (isset($GLOBALS['sql_escapes'][$str])) {
- // Then use it instead
- return $GLOBALS['sql_escapes'][$str];
- } // END - if
-
- // Secure string first? (which is the default behaviour!)
- if ($secureString === true) {
- // Then do it here
- $str = secureString($str, $strip);
- } // END - if
+ if (!isset($GLOBALS['sql_escapes'][''.$str.''])) {
+ // Secure string first? (which is the default behaviour!)
+ if ($secureString === true) {
+ // Then do it here
+ $str = secureString($str, $strip);
+ } // END - if
- if (!SQL_IS_LINK_UP()) {
- // Fall-back to smartAddSlashes() when there is no link
- $ret = smartAddSlashes($str);
- } elseif (function_exists('mysql_real_escape_string')) {
- // The new and improved version
- //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):str={$str}<br />");
- $ret = mysql_real_escape_string($str, SQL_GET_LINK());
- } elseif (function_exists('mysql_escape_string')) {
- // The obsolete function
- $ret = mysql_escape_string($str, SQL_GET_LINK());
- } else {
- // If nothing else works, fall back to smartAddSlashes() again
- $ret = smartAddSlashes($str);
- }
+ if (!SQL_IS_LINK_UP()) {
+ // Fall-back to smartAddSlashes() when there is no link
+ $ret = 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 />");
+ $ret = mysql_real_escape_string($str, SQL_GET_LINK());
+ } elseif (function_exists('mysql_escape_string')) {
+ // The obsolete function
+ $ret = mysql_escape_string($str, SQL_GET_LINK());
+ } else {
+ // If nothing else works, fall back to smartAddSlashes() again
+ $ret = smartAddSlashes($str);
+ }
- // Cache result
- $GLOBALS['sql_escapes'][$str] = $ret;
+ // Cache result
+ $GLOBALS['sql_escapes'][''.$str.''] = $ret;
+ } // END - if
// Return it
- return $ret;
+ return $GLOBALS['sql_escapes'][''.$str.''];
}
// SELECT query string from table, columns and so on... ;-)
// 123 4 4 3 3 4 4 32 23 4 4 3 3 4 4 321
if (((SQL_NUMROWS($result) == 0) && (strpos($sql, 'ADD') !== false)) || ((SQL_NUMROWS($result) == 1) && (strpos($sql, 'DROP') !== false))) {
// Do the query
- //* DEBUG: */ outputHtml(__LINE__.':'.$sql."<br />");
+ //* DEBUG: */ print(__LINE__.':'.$sql."<br />");
$result = SQL_QUERY($sql, $F, $L, false);
} // END - if
} elseif ((getConfig('_TABLE_TYPE') == 'InnoDB') && (strpos($sql, 'FULLTEXT') !== false)) {
while (strpos($columnName, ',') !== false) {
// Use last
$columnName = str_replace('`', '', $tableArray[count($tableArray) - $begin]);
- //* DEBUG: */ outputHtml(__LINE__.':'.$columnName."----------------".$begin."<br />");
+ //* DEBUG: */ print(__LINE__.':'.$columnName."----------------".$begin."<br />");
// Remove brackes
$columnName = str_replace('(', '', str_replace(')', '', $columnName));
- //* DEBUG: */ outputHtml(__LINE__.':'.$columnName."----------------".$begin."<br />");
+ //* DEBUG: */ print(__LINE__.':'.$columnName."----------------".$begin."<br />");
// Continue
$begin++;
$skip = false;
while ($content = SQL_FETCHARRAY($result)) {
// Is it found?
- //* DEBUG: */ outputHtml("<pre>".print_r($content, true)."</pre>");
+ //* DEBUG: */ print("<pre>".print_r($content, true)."</pre>");
if (($content['Column_name'] == $columnName) || ($content['Key_name'] == $columnName)) {
// Skip this query!
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Skiped: %s", $sql));
// Shall we run it?
if ($skip === false) {
// Send it to the SQL_QUERY() function
- //* DEBUG: */ outputHtml(__LINE__.':'.$sql."<br />");
+ //* DEBUG: */ print(__LINE__.':'.$sql."<br />");
$result = SQL_QUERY($sql, $F, $L, false);
} // END - if
} else {
// Other ALTER TABLE query
- //* DEBUG: */ outputHtml(__LINE__.':'.$sql."<br />");
+ //* DEBUG: */ print(__LINE__.':'.$sql."<br />");
$result = SQL_QUERY($sql, $F, $L, false);
}