作者 邓超

x

@@ -63,10 +63,21 @@ class HotMail { @@ -63,10 +63,21 @@ class HotMail {
63 63
64 64
65 $maxId = $this->db->value("select `id` from `lists` order by `id` desc limit 1"); 65 $maxId = $this->db->value("select `id` from `lists` order by `id` desc limit 1");
66 - for ($i=0;$i<ceil($maxId/1000);$i++){  
67 - $this->run(range($i*1000,($i+1)*1000)); 66 + $id = 0;
  67 + while (1){
  68 + $ids = [];
  69 + for ($i=0;$i<1000;$i++){
  70 + $ids[] = $i+$id;
  71 + }
  72 + $id = end($ids);
  73 +
  74 + $this->run($ids);
  75 + if($id>$maxId){
  76 + break;
  77 + }
68 } 78 }
69 79
  80 +
70 echo '已执行完成'.PHP_EOL; 81 echo '已执行完成'.PHP_EOL;
71 } 82 }
72 83
@@ -74,7 +85,7 @@ class HotMail { @@ -74,7 +85,7 @@ class HotMail {
74 private $folder = []; 85 private $folder = [];
75 86
76 private function run($id){ 87 private function run($id){
77 - $list = $this->db->all(\Model\listsSql::first(dbWhere(['id'=>$id,'is_hots'=>0]),'`id`,`from`,`to`,`folder_id`')); 88 + $list = $this->db->all(\Model\listsSql::all(dbWhere(['id'=>$id,'is_hots'=>0]),'`id`,`from`,`to`,`folder_id`'));
78 foreach ($list as $item){ 89 foreach ($list as $item){
79 if(empty($this->folder[$item['folder_id']])){ 90 if(empty($this->folder[$item['folder_id']])){
80 $this->folder[$item['folder_id']] = folderAlias($this->db->value(\Model\folderSql::first($item['folder_id'],'folder'))); 91 $this->folder[$item['folder_id']] = folderAlias($this->db->value(\Model\folderSql::first($item['folder_id'],'folder')));