- if (!SQL_IS_LINK_UP()) return false;
+ if (!SQL_IS_LINK_UP()) {
+ // We should not quietly ignore this!
+ trigger_error(sprintf("Cannot query database: sql_string=%s,file=%s,line=%s",
+ $sql_string,
+ basename($F),
+ $L
+ ));
+
+ // Return 'false' because it has failed
+ return false;
+ } // END - if
// 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)));
// Replace {!_MYSQL_PREFIX!} with constant, closes #84. Thanks to profi-concept
// 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)));
// Replace {!_MYSQL_PREFIX!} with constant, closes #84. Thanks to profi-concept
// Debug output
//* DEBUG: */ print "Query=<pre>".$sql_string."</pre>, affected=<strong>".SQL_AFFECTEDROWS()."</strong>, numrows=<strong>".SQL_NUMROWS($result)."</strong><br />\n";
// Debug output
//* DEBUG: */ print "Query=<pre>".$sql_string."</pre>, affected=<strong>".SQL_AFFECTEDROWS()."</strong>, numrows=<strong>".SQL_NUMROWS($result)."</strong><br />\n";
- $fp = fopen(constant('PATH')."inc/cache/mysql.log", 'a') or app_die(__FILE__, __LINE__, "Cannot write mysql.log!");
+ $fp = fopen(constant('PATH') . 'inc/cache/mysql.log', 'a') or app_die(__FILE__, __LINE__, "Cannot write mysql.log!");
- fwrite($fp, $F."(LINE=".$L."|NUM=".SQL_NUMROWS($result)."|AFFECTED=".SQL_AFFECTEDROWS()."|QUERYTIME:".$queryTime."): ".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");
incrementConfigEntry('db_hits', getConfig('db_hits_run'));
// Update counter for db/cache
incrementConfigEntry('db_hits', getConfig('db_hits_run'));
// Update counter for db/cache
- UPDATE_CONFIG(array('db_hits', 'cache_hits'), array(getConfig(('db_hits')), getConfig(('cache_hits'))));
+ updateConfiguration(array('db_hits', 'cache_hits'), array(getConfig('db_hits'), getConfig('cache_hits')));
- $close = mysql_close(SQL_GET_LINK()) or addFatalMessage(__FUNCTION__, __LINE__, $F." (".$L."):".mysql_error());
+ $close = mysql_close(SQL_GET_LINK())
+ or addFatalMessage(__FUNCTION__, __LINE__, $F . ' (' . $L . '):'.mysql_error());
// Debugging
//
//* DEBUG: */ $fp = fopen(constant('PATH')."inc/cache/escape_debug.log", 'a') or app_die(__FILE__, __LINE__, "Cannot write debug.log!");
// Debugging
//
//* DEBUG: */ $fp = fopen(constant('PATH')."inc/cache/escape_debug.log", 'a') or app_die(__FILE__, __LINE__, "Cannot write debug.log!");
- //* DEBUG: */ fwrite($fp, $F."(".$L."): ".str_replace("\r", '', str_replace("\n", " ", $eval))."\n");
+ //* DEBUG: */ fwrite($fp, $F.'('.$L."): ".str_replace("\r", '', str_replace("\n", " ", $eval))."\n");
- $sql = "SELECT `".implode("`,`", $columns)."` FROM `{!_MYSQL_PREFIX!}_%s` WHERE ``='%s' LIMIT 1";
+ $sql = "SELECT `".implode("`,`", $columns)."` FROM `{!_MYSQL_PREFIX!}_%s` WHERE `%s`='%s' LIMIT 1";
- // 12 3 3 2 2 3 3 2 2 3 3 21
- $noIndex = ((ereg("INDEX", $sql) == false) && (ereg("FULLTEXT", $sql) == false) && (ereg("UNIQUE", $sql) == false));
+ $noIndex = (
+ (
+ strpos($sql, 'INDEX') === false
+ ) && (
+ strpos($sql, 'FULLTEXT') === false
+ ) && (
+ strpos($sql, 'UNIQUE') === false
+ )
+ );
array($tableName, $columnName), __FILE__, __LINE__);
// Do we have no entry on ADD or an entry on DROP?
array($tableName, $columnName), __FILE__, __LINE__);
// Do we have no entry on ADD or an entry on DROP?
- // 123 4 4 3 3 4 432 23 4 4 3 3 4 4321
- if (((SQL_NUMROWS($result) == 0) && (ereg("ADD", $sql))) || ((SQL_NUMROWS($result) == 1) && (ereg("DROP", $sql)))) {
+ // 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))) {
$result = SQL_QUERY($sql, $F, $L, false);
} // END - if
$result = SQL_QUERY($sql, $F, $L, false);
} // END - if
// Skip this query silently
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,file=%s,line=%s", $sql, $F, $L));
} elseif (!$noIndex) {
// And column name as well
// Skip this query silently
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,file=%s,line=%s", $sql, $F, $L));
} elseif (!$noIndex) {
// And column name as well
- if (in_array(strtoupper($columnName), array("INDEX", "UNIQUE", "KEY", "FULLTEXT"))) {
+ if (in_array(strtoupper($columnName), array('INDEX', 'UNIQUE', 'KEY', 'FULLTEXT'))) {
- $begin = 1; $columnName = ",";
- while (strpos($columnName, ",") !== false) {
+ $begin = 1; $columnName = ',';
+ while (strpos($columnName, ',') !== false) {
- $columnName = str_replace("`", '', $tableArray[count($tableArray) - $begin]);
- //* DEBUG: */ print __LINE__.":".$columnName."----------------".$begin."<br />\n";
+ $columnName = str_replace('`', '', $tableArray[count($tableArray) - $begin]);
+ //* DEBUG: */ print __LINE__.':'.$columnName."----------------".$begin."<br />\n";
- $columnName = str_replace("(", '', str_replace(")", '', $columnName));
- //* DEBUG: */ print __LINE__.":".$columnName."----------------".$begin."<br />\n";
+ $columnName = str_replace('(', '', str_replace(')', '', $columnName));
+ //* DEBUG: */ print __LINE__.':'.$columnName."----------------".$begin."<br />\n";
$result = SQL_QUERY($sql, $F, $L, false);
} // END - if
} else {
// Other ALTER TABLE query
$result = SQL_QUERY($sql, $F, $L, false);
} // END - if
} else {
// Other ALTER TABLE query
$result = SQL_QUERY($sql, $F, $L, false);
}
$result = SQL_QUERY($sql, $F, $L, false);
}