// Calculate sum (default) or count records of given criteria
function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = FALSE, $add = '', $mode = '=') {
- // Init count/sum
- $data['res'] = '0';
-
+ // Debug message
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',tableName=' . $tableName . ',lookFor=' . $lookFor . ',whereStatement=' . $whereStatement . ',add=' . $add);
if ((empty($search)) && ($search != '0')) {
// Count or sum whole table?
if ($countRows === TRUE) {
// Count whole table
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'COUNT!');
$result = SQL_QUERY_ESC('SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`' . $add . ' LIMIT 1',
array(
$lookFor,
), __FUNCTION__, __LINE__);
} else {
// Sum whole table
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SUM!');
$result = SQL_QUERY_ESC('SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`' . $add . ' LIMIT 1',
array(
$lookFor,
`html_msg`
) VALUES (
'%s',
- %s',
+ '%s',
'%s',
%s,
%s,
foreach ($orderByColumns as $orderByColumn => $array) {
// Get keys (table/alias) and values (sorting itself)
$table = trim(implode('', array_keys($array)));
- $sorting = trim(implode('', array_keys($array)));
+ $sorting = trim(implode('', array_values($array)));
// table/alias can be omitted
if (!empty($table)) {
} // END - if
// Debug message
- //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',columnName[' . gettype($columnName) . ']=' . $columnName . ',filterFunctions=' . $filterFunctions[$key] . ',extraValues=' . intval(isset($extraValues[$key])) . ',extraValuesName=' . intval(isset($extraValues[$columnName . '_list'])) . '<br />');
+ //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',columnName[' . gettype($columnName) . ']=' . $columnName . ',filterFunctions=' . $filterFunctions[$key] . ',extraValues=' . intval(isset($extraValues[$key])) . ',extraValuesName=' . intval(isset($extraValues[$columnName . '_list'])));
// Copy entry securely to the final arrays
$sqlColumns[$key] = SQL_ESCAPE($columnName);
// Then log it
//* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',sqlValues[' . $key . '][' . gettype($sqlValues[$key]) . ']=' . $sqlValues[$key] . ' - AFTER!');
} // END - if
- } elseif ((isset($filterFunctions[$key])) && (!empty($filterFunctions[$key])) && (!empty($sqlValues[$key]))) {
+ } elseif (isset($filterFunctions[$key])) {
// Debug mode enabled?
if (isDebugModeEnabled()) {
// Then log it
// Run the SQL query
SQL_QUERY($sql, __FUNCTION__, __LINE__);
- // Add id
+ // Add id number
setPostRequestElement('id', SQL_INSERTID());
// Prepare filter data array