20230309075428_update_data01.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use app\model\Video as VideoModel;
  5. use app\model\CompanyStrength as CompanyStrengthModel;
  6. class UpdateData01 extends Migrator
  7. {
  8. /**
  9. * Change Method.
  10. *
  11. * Write your reversible migrations using this method.
  12. *
  13. * More information on writing migrations is available here:
  14. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  15. *
  16. * The following commands can be used in this method and Phinx will
  17. * automatically reverse them when rolling back:
  18. *
  19. * createTable
  20. * renameTable
  21. * addColumn
  22. * renameColumn
  23. * addIndex
  24. * addForeignKey
  25. *
  26. * Remember to call "create()" or "update()" and NOT "save()" when working
  27. * with the Table class.
  28. */
  29. public function change()
  30. {
  31. // 东莞鲁班 数据迁移 3-60百问百答视频 (移至公司实力 快问快答)
  32. $where = [
  33. ['type','=',2388],
  34. ['root_id','=',1023]
  35. ];
  36. $list = VideoModel::where($where)->column('*');
  37. foreach ($list as $k => $v) {
  38. CompanyStrengthModel::create([
  39. 'root_id'=>1023,
  40. 'cate'=>'快问快答',
  41. 'title'=>$v['title'],
  42. 'pics'=>$v['video_url'],
  43. 'cover'=>$v['cover'],
  44. 'addtime'=>date('Y-m-d H:i:s'),
  45. 'updatetime'=>date('Y-m-d H:i:s'),
  46. 'del'=>0,
  47. 'publish'=>1,
  48. 'employee_id'=>4401,
  49. 'difference'=>1,
  50. 'video_type'=>0,
  51. 'desc'=>''
  52. ]);
  53. }
  54. }
  55. }