= {?coupon_autopurge_time?} ORDER BY `id` ASC', __FILE__, __LINE__); // Are there entries? if (sqlNumRows($result) > 0) { // Init variables $out = ''; $ids = array(); // Start purging all while ($content = sqlFetchArray($result)) { // Add id array_push($ids, $content['id']); // Translate some data $content['coupon_created'] = generateDateTime($content['coupon_created'], '2'); $content['coupon_expired'] = generateDateTime($content['coupon_expired'], '2'); // Load email row template $out .= loadEmailTemplate('admin_coupon_purge_row', $content); } // END - while // Purge all entries sqlQuery('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_coupon_data` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`coupon_expired`)) >= {?coupon_autopurge_time?}', __FILE__, __LINE__); // Purge also user entries sqlQueryEscaped("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_coupons` WHERE `coupon_id` IN (%s) LIMIT %s", array( implode(',', $ids), count($ids) ), __FILE__, __LINE__); // Send admin notification sendAdminNotification('{--ADMIN_COUPON_PURGE_SUBJECT--}', 'admin_coupon_purge', $out); } // END - if // Free result sqlFreeResult($result); // [EOF] ?>