123456789101112131415161718192021222324 |
- <?php
- use think\migration\Migrator;
- use think\migration\db\Column;
- use app\model\Permission;
- use app\model\Video;
- use app\model\Footprints;
- class AddOldVisitDueTimeToVideo extends Migrator
- {
- public function change()
- {
- $list = Video::column('id,visit_due_time');
- foreach($list as $key=>$val){
- $foot_where = [];
- $foot_where[] = ['pipe_type', '=', 'video'];
- $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 Video;
- $mod->saveAll($all);
- }
- }
- ?>
|