// 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) {
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
// 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!');
}