// 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,