计划任务定时清理掉设置后的内容
主要针对单表删除(日志,);对于多表删除,不太好用(订单+订单商品+订单日志)
结构:
1.计划任务语言包:languageszh_cncron
2.php文件:includesmodulescron
实例
a.语言包
<?php global $_LANG; $_LANG['depot_order'] = '微仓采购订单'; $_LANG['depot_order_desc'] = '删除微仓采购订单,无效订单+订单商品'; $_LANG['depot_order_day'] = '删除几天前未确认订单'; $_LANG['depot_order_day_range']['1'] = '1天'; $_LANG['depot_order_day_range']['7'] = '7天'; $_LANG['depot_order_day_range']['15'] = '15天'; $_LANG['depot_order_day_range']['30'] = '30天'; $_LANG['depot_order_day_range']['90'] = '90天'; ?>
b.php文件
<?php if (!defined('IN_ECS')) { die('Hacking attempt'); } $cron_lang = ROOT_PATH . 'languages/' .$GLOBALS['_CFG']['lang']. '/cron/depot_order.php'; if (file_exists($cron_lang)) { global $_LANG; include_once($cron_lang); } /* 模块的基本信息 */ if (isset($set_modules) && $set_modules == TRUE) { $i = isset($modules) ? count($modules) : 0; /* 代码 */ $modules[$i]['code'] = basename(__FILE__, '.php'); /* 描述对应的语言项 */ $modules[$i]['desc'] = 'depot_order_desc'; /* 作者 */ $modules[$i]['author'] = '亮星科技'; /* 网址 */ $modules[$i]['website'] = 'http://www.brightdiva.hk'; /* 版本号 */ $modules[$i]['version'] = '1.0.0'; /* 配置信息 */ $modules[$i]['config'] = array( array('name' => 'depot_order_day', 'type' => 'select', 'value' => '1'), ); return; } empty($cron['depot_order_day']) && $cron['depot_order_day'] = 7; $deltime = gmtime() - $cron['depot_order_day'] * 3600 * 24; $sql = "DELETE o,g FROM ".$ecs->table('depot_order')." AS o,".$ecs->table('depot_goods')." AS g where o.order_id = g.order_id and o.order_status=0 and o.pay_status= 0 and o.add_time < '$deltime'"; $db->query($sql); ?>