123456789101112131415161718192021222324 |
- <?php
- use think\migration\Migrator;
- use think\migration\db\Column;
- use app\model\Permission;
- use app\model\Article;
- use app\model\Footprints;
- class AddOldVisitDueTimeToArticle extends Migrator
- {
- public function change()
- {
- $list = Article::column('id,visit_due_time');
- foreach($list as $key=>$val){
- $foot_where = [];
- $foot_where[] = ['pipe_type', '=', 'article'];
- $foot_where[] = ['pipe_id', '=', $val['id']];
- $alltime = Footprints::where($foot_where)->sum('visit_due_time');
- if(!empty($alltime)) $all[] = ['id'=>$val['id'],'visit_due_time'=>$alltime];
- }
- $mod = new Article;
- $mod->saveAll($all);
- }
- }
- ?>
|