]> git.mxchange.org Git - mailer.git/blobdiff - inc/referal-functions.php
Some fixes:
[mailer.git] / inc / referal-functions.php
index 57b00298b196776d9576e397c32268c8e856bd33..cec12c40a71e63db515d4e03b426792a498aa814 100644 (file)
@@ -372,7 +372,7 @@ ORDER BY
                        $row['points'] = getTotalPoints($row['refid']);
 
                        // Get unconfirmed mails
-                       $row['unconfirmed']  = countSumTotalData($row['refid'], 'user_links', 'id', 'userid', true);
+                       $row['unconfirmed'] = getTotalUnconfirmedMails($row['refid']);
 
                        // Init click rate with zero
                        $row['click_rate'] = '0';
@@ -624,6 +624,7 @@ function flushReferalTableToDatabase ($userid) {
 
        // Prepare SQL
        $SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`,`level`,`refid`) VALUES ';
+       $executeSql = false;
 
        // Now walk through the array, first levels
        foreach ($GLOBALS['referal_refid'][$userid] as $level=>$levelArray) {
@@ -643,6 +644,9 @@ function flushReferalTableToDatabase ($userid) {
                        if ($count == 0) {
                                // Then add it to the SQL
                                $SQL .= '(' . $userid . ',' . $level . ',' . $refid . '),';
+
+                               // Some has been added, so execute the query
+                               $executeSql = true;
                        } // END - if
                } // END - foreach
        } // END - foreach
@@ -652,7 +656,9 @@ function flushReferalTableToDatabase ($userid) {
 
        // And run it
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL=' . $SQL);
-       SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+       if ($executeSql === true) {
+               SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+       } // END - if
 
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!');
 }