UpdateYeahMonthToUserWithdrawalsSeeder.php 729 B

123456789101112131415161718192021222324252627
  1. <?php
  2. use app\common\model\user\Withdraw;
  3. use think\migration\Seeder;
  4. class UpdateYeahMonthToUserWithdrawalsSeeder extends Seeder
  5. {
  6. /**
  7. * Run Method.
  8. *
  9. * Write your database seeder using this method.
  10. *
  11. * More information on writing seeders is available here:
  12. * http://docs.phinx.org/en/latest/seeding.html
  13. */
  14. public function run()
  15. {
  16. $m = new Withdraw();
  17. $lists = $m->field('id,create_time')->select();
  18. if ($lists){
  19. foreach ($lists as $list){
  20. $ym = substr($list['create_time'],0,4).substr($list['create_time'],5,2);
  21. $m->where('id',$list['id'])->update(['year_month'=>intval($ym)]);
  22. }
  23. }
  24. }
  25. }