]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/earning_functions.php
Updated copyright notice as there are changes in this year
[mailer.git] / inc / libs / earning_functions.php
index 3f747490bfa1fd97e3aa5250c057ecf301444c42..345a06cd5386667752b94b456345b31fac7f7f09 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -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;
 }
@@ -126,7 +113,7 @@ function insertMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') {
 
        // Prepare content
        $content = array(
-               'insert_id'    => SQL_INSERTID(),
+               'insert_id'    => SQL_INSERT_ID(),
                'earning_id'   => bigintval($earningId),
                'daily_amount' => bigintval($dailyAmount),
                'is_active'    => $isActive