From: Roland Häder Date: Wed, 9 Jan 2013 22:20:07 +0000 (+0000) Subject: Use countSumTotalData() instead of SQL query X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cb22480488263dac67caa6f5b6476421527900ad;p=mailer.git Use countSumTotalData() instead of SQL query --- diff --git a/inc/libs/earning_functions.php b/inc/libs/earning_functions.php index 3f747490bf..a1bb9a79f7 100644 --- a/inc/libs/earning_functions.php +++ b/inc/libs/earning_functions.php @@ -87,18 +87,8 @@ function generateMemberEarningDataTable ($earningProvider) { // Handle earning id function doMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { - // Does the user already have this earning? - $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS `cnt` FROM `{?_MYSQL_PREFIX?}_user_earning` WHERE `earning_id`=%s AND `earning_userid`=%s LIMIT 1", - array( - bigintval($earningId), - getMemberId() - ), __FUNCTION__, __LINE__); - - // Get the count - list($count) = SQL_FETCHROW($result); - // Does the user have this? - if ($count == 1) { + if (countSumTotalData(bigintval($earningId), 'user_earning', 'id', 'earning_id', TRUE, ' AND `earning_userid`=' . getMemberId()) == 1) { // Then update it $status = updateMemberEarning($earningId, $dailyAmount, $isActive); } else { @@ -106,9 +96,6 @@ function doMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { $status = insertMemberEarning($earningId, $dailyAmount, $isActive); } - // Free result - SQL_FREERESULT($result); - // Return status return $status; } diff --git a/inc/modules/frametester.php b/inc/modules/frametester.php index 93c5eb126a..09898ff036 100644 --- a/inc/modules/frametester.php +++ b/inc/modules/frametester.php @@ -46,13 +46,13 @@ if (isGetRequestElementSet('order')) { // Order number placed, is he also logged in? if (isMember()) { // Ok, test passed... :) - $result = SQL_QUERY_ESC("SELECT `subject`, `url` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s AND `sender`=%s AND `data_type`='TEMP' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `url` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s AND `sender`=%s AND `data_type`='TEMP' LIMIT 1", array(bigintval(getRequestElement('order')), getMemberId()), __FILE__, __LINE__); // Finally is the entry valid? if (SQL_NUMROWS($result) == 1) { // Load subject and URL (but forwhat do we need the subject line here??? - list($sub, $url) = SQL_FETCHROW($result); + list($url) = SQL_FETCHROW($result); // This fixes a white page setPostRequestElement('url', $url); diff --git a/inc/modules/guest/what-mediadata.php b/inc/modules/guest/what-mediadata.php index df1d0e8d75..8828b53ffd 100644 --- a/inc/modules/guest/what-mediadata.php +++ b/inc/modules/guest/what-mediadata.php @@ -163,7 +163,7 @@ $content['total_logins'] = $logins; $total = countSumTotalData('Y', 'refbanner', 'id', 'visible', TRUE); // Total views and clicks -$result = SQL_QUERY("SELECT SUM(`counter`) AS `cnt`, SUM(`clicks`) AS `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__); +$result = SQL_QUERY("SELECT SUM(`counter`) AS `views`, SUM(`clicks`) AS `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__); list($views, $clicks) = SQL_FETCHROW($result); SQL_FREERESULT($result); diff --git a/inc/referral-functions.php b/inc/referral-functions.php index 20b3da0169..1b95e84ee9 100644 --- a/inc/referral-functions.php +++ b/inc/referral-functions.php @@ -699,12 +699,7 @@ function flushReferralTableToDatabase ($userid) { foreach ($levelArray as $refid) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid); // Query the user_refs table - list($count) = SQL_FETCHROW(SQL_QUERY_ESC('SELECT COUNT(`id`) AS `count` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s AND `refid`=%s LIMIT 1', - array( - $userid, - $level, - $refid - ), __FUNCTION__, __LINE__)); + $count = countSumTotalData(bigintval($userid), 'user_refs', 'id', 'userid', TRUE, ' AND `level`=' . bigintval($level) . ' AND `refid`=' . bigintval($refid)); // Is there no entry? if ($count == 0) {