作者 邓超

预热邮件

@@ -63,18 +63,21 @@ class HotMailArchive { @@ -63,18 +63,21 @@ class HotMailArchive {
63 _echo('正在移动 '.$fid); 63 _echo('正在移动 '.$fid);
64 $list = $this->db->all(\Model\listsSql::first(dbWhere(['folder_id'=>$fid,'is_hots'=>1])).'000'); 64 $list = $this->db->all(\Model\listsSql::first(dbWhere(['folder_id'=>$fid,'is_hots'=>1])).'000');
65 if($list){ 65 if($list){
66 - foreach ($list as $item){  
67 - try {  
68 - $ret = $this->db->throw()->insert('lists_hot',$item,false);  
69 - }catch (Throwable $e){  
70 - $this->db->delete('lists_hot',['id'=>$item['id']]);  
71 - unset($item['updated_at']);  
72 - $ret = $this->db->throw()->insert('lists_hot',$item,false); 66 + $this->db->transaction(function () use ($list){
  67 + foreach ($list as $item){
  68 + try {
  69 + $ret = $this->db->throw()->insert('lists_hot',$item,false);
  70 + }catch (Throwable $e){
  71 + $this->db->delete('lists_hot',['id'=>$item['id']]);
  72 + unset($item['updated_at']);
  73 + $ret = $this->db->throw()->insert('lists_hot',$item,false);
  74 + }
  75 + if($ret){
  76 + $this->db->delete(listsSql::$table,['id'=>$item['id']]);
  77 + }
73 } 78 }
74 - if($ret){  
75 - $this->db->delete(listsSql::$table,['id'=>$item['id']]);  
76 - }  
77 - } 79 + });
  80 +
78 $this->move($fid); 81 $this->move($fid);
79 } 82 }
80 83