//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'file=' . basename($file) . ',line=' . $line . ',sql=' . $GLOBALS['last_sql']);
$result = mysql_query($GLOBALS['last_sql'], getSqlLink())
or logSqlError($file, $line, 'file='. basename($file) . ',line=' . $line . ':mysql_error()=' . mysql_error() . ',last_query=' . $GLOBALS['last_sql']);
- //* DEBUG: */ logDebugMessage($file, $line, 'sql=' . $GLOBALS['last_sql'] . ',affected=' . sqlAffectedRows() . ',numRows='.(isValidSqlLink($result) ? sqlNumRows($result) : gettype($result)));
+ //* DEBUG: */ logDebugMessage($file, $line, 'sql=' . $GLOBALS['last_sql'] . ',affected=' . sqlAffectedRows() . ',numRows='.(isValidSqlResult($result) ? sqlNumRows($result) : gettype($result)));
// Calculate query time
$queryTime = microtime(TRUE) - $querytimeBefore;
} // END - if
// Append debug line
- appendLineToFile(getCachePath() . 'mysql.log', basename($file) . '|LINE=' . $line . '|NUM=' . (isValidSqlLink($result) ? sqlNumRows($result) : 'false') . '|AFFECTED=' . sqlAffectedRows() . '|QUERYTIME:' . ($queryTime * 1000) . 'ms): ' . str_replace(array(chr(13), PHP_EOL), array('', ' '), $GLOBALS['last_sql']));
+ appendLineToFile(getCachePath() . 'mysql.log', basename($file) . '|LINE=' . $line . '|NUM=' . (isValidSqlResult($result) ? sqlNumRows($result) : 'false') . '|AFFECTED=' . sqlAffectedRows() . '|QUERYTIME:' . ($queryTime * 1000) . 'ms): ' . str_replace(array(chr(13), PHP_EOL), array('', ' '), $GLOBALS['last_sql']));
} // END - if
// Increment stats entry
if (isset($GLOBALS['sql_numrows'][intval($resource)])) {
// Use cache
$lines = $GLOBALS['sql_numrows'][intval($resource)];
- } elseif (isValidSqlLink($resource)) {
+ } elseif (isValidSqlResult($resource)) {
// Get the count of rows from database
$lines = mysql_num_rows($resource);
// SQL fetch row
function sqlFetchRow ($resource) {
// Is $resource valid?
- if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) return FALSE;
+ if ((!isValidSqlResult($resource)) || (!isSqlLinkUp())) return FALSE;
// Fetch the data and return it
return mysql_fetch_row($resource);
// SQL fetch array
function sqlFetchArray ($resource) {
// Is $resource valid?
- if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) return FALSE;
+ if ((!isValidSqlResult($resource)) || (!isSqlLinkUp())) return FALSE;
// Load row as array from database
$row = mysql_fetch_assoc($resource);
// SQL result
function sqlResult ($resource, $row, $field = '0') {
// Is $resource valid?
- if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) return FALSE;
+ if ((!isValidSqlResult($resource)) || (!isSqlLinkUp())) return FALSE;
// Run the result command
$result = mysql_result($resource, $row, $field);
// SQL free result
function sqlFreeResult ($resource) {
- if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) {
+ if ((!isValidSqlResult($resource)) || (!isSqlLinkUp())) {
// Abort here
return FALSE;
} // END - if
}
// Checks whether given result is a valid SQL result
-function isSqlResult ($result) {
+function isValidSqlResult ($resultResource) {
// TODO: Can't this be made better?
- return is_resource($result);
+ return is_resource($resultResource);
}
// [EOF]
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'file=' . basename($file) . ',line=' . $line . ',sql=' . $GLOBALS['last_sql']);
$result = mysqli_query(getSqlLink(), $GLOBALS['last_sql'])
or logSqlError($file, $line, 'file='. basename($file) . ',line=' . $line . ':mysqli_error()=' . mysqli_error(getSqlLink()) . ',last_query=' . $GLOBALS['last_sql']);
- //* DEBUG: */ logDebugMessage($file, $line, 'sql=' . $GLOBALS['last_sql'] . ',affected=' . sqlAffectedRows() . ',numRows='.(isValidSqlLink($result) ? sqlNumRows($result) : gettype($result)));
+ //* DEBUG: */ logDebugMessage($file, $line, 'sql=' . $GLOBALS['last_sql'] . ',affected=' . sqlAffectedRows() . ',numRows='.(isValidSqlResult($result) ? sqlNumRows($result) : gettype($result)));
// Calculate query time
$queryTime = microtime(TRUE) - $querytimeBefore;
} // END - if
// Append debug line
- appendLineToFile(getCachePath() . 'mysql.log', basename($file) . '|LINE=' . $line . '|NUM=' . (isValidSqlLink($result) ? sqlNumRows($result) : 'false') . '|AFFECTED=' . sqlAffectedRows() . '|QUERYTIME:' . ($queryTime * 1000) . 'ms): ' . str_replace(array(chr(13), PHP_EOL), array('', ' '), $GLOBALS['last_sql']));
+ appendLineToFile(getCachePath() . 'mysql.log', basename($file) . '|LINE=' . $line . '|NUM=' . (isValidSqlResult($result) ? sqlNumRows($result) : 'false') . '|AFFECTED=' . sqlAffectedRows() . '|QUERYTIME:' . ($queryTime * 1000) . 'ms): ' . str_replace(array(chr(13), PHP_EOL), array('', ' '), $GLOBALS['last_sql']));
} // END - if
// Increment stats entry
// SQL fetch row
function sqlFetchRow ($resource) {
// Is $resource valid?
- if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) return FALSE;
+ if ((!isValidSqlResult($resource)) || (!isSqlLinkUp())) return FALSE;
// Fetch the data and return it
return mysqli_fetch_row($resource);
// SQL fetch array
function sqlFetchArray ($resource) {
// Is $resource valid?
- if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) return FALSE;
+ if ((!isValidSqlResult($resource)) || (!isSqlLinkUp())) return FALSE;
// Load row as array from database
$row = mysqli_fetch_assoc($resource);
// SQL result
function sqlResult ($resource, $row, $field = '0') {
// Is $resource valid?
- if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) return FALSE;
+ if ((!isValidSqlResult($resource)) || (!isSqlLinkUp())) return FALSE;
// Run the result command
$result = mysqli_result($resource, $row, $field);
// SQL free result
function sqlFreeResult ($resource) {
- if ((!isValidSqlLink($resource)) || (!isSqlLinkUp())) {
+ if ((!isValidSqlResult($resource)) || (!isSqlLinkUp())) {
// Abort here
return FALSE;
} // END - if
// Checks whether given link is a valid SQL link
function isValidSqlLink ($linkInstance) {
// Is it an object?
- $isValid = (($linkInstance instanceof mysqli) || ($linkInstance instanceof mysqli_result));
+ $isValid = ($linkInstance instanceof mysqli);
// Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'linkInstance[]=' . gettype($linkInstance). ',isValid=' . intval($isValid));
}
// Checks whether given result is really a result
-function isSqlResult ($resultInstance) {
+function isValidSqlResult ($resultInstance) {
// Is it a resource?
$isValid = ($resultInstance instanceof mysqli_result);
} else {
// No name found
$data['title'] = '{%message,UNKNOWN_MODULE_DETECTED_TITLE=' . $module . '%}';
- if ((isSqlResult($result)) && (ifSqlHasZeroNumRows($result))) {
+ if ((isValidSqlResult($result)) && (ifSqlHasZeroNumRows($result))) {
// Add module to database and ignore return value
checkModulePermissions($module);
} // END - if
// Load main template
loadTemplate('admin_list_notify_emails', FALSE, $content);
}
-} elseif ((sqlNumRows($result_max) === 0) && (isSqlResult($result_max))) {
+} elseif ((sqlNumRows($result_max) === 0) && (isValidSqlResult($result_max))) {
// No notifications found
displayMessage('{--ADMIN_NO_NOTIFICATIONS--}');
}
array($tableName), __FUNCTION__, __LINE__);
// Is a link there?
- if (!isValidSqlLink($result)) {
+ if (!isValidSqlResult($result)) {
// Is installation phase?
if (isInstaller()) {
// Then silently abort here
), __FUNCTION__, __LINE__);
// Is a link there?
- if (!isValidSqlLink($result)) {
+ if (!isValidSqlResult($result)) {
// Is installation phase?
if (isInstaller()) {
// Then silently abort here
$result = sqlQueryEscaped("SHOW INDEX FROM `%s`", array($tableName), __FUNCTION__, __LINE__);
// Is a link there?
- if (!isValidSqlLink($result)) {
+ if (!isValidSqlResult($result)) {
// Is installation phase?
if (isInstaller()) {
// Then silently abort here