setName('supplier') ->setDescription('the CopyData command'); } protected function execute(Input $input, Output $output) { // 指令输php出 $this->db =Db::connect("mysql2"); $data = $this->GetData(); $list=[]; foreach ($data as $key=>$value){ $relas = Db::name('supplier_info')->where("code","=",$value['code'])->find(); if($relas){ Db::name('supplier_info')->where("code","=",$value['code'])->save($value); }else{ Db::name('supplier_info')->insert($value); } } $output->writeln('CopyData'); } private function GetData(){ $date = date("Y-m-d H:i:s",strtotime("-1 day")); $data = $this->db->table("iw48m_Supplier_info")->alias('a')->where("a.modifiedTime",">=",$date) ->field("name, ifnull(sequenceNo,'') as code, ifnull(ShortText1614742711656,'') 'source', ifnull(text1614751047046,'') 'contector', ifnull(text1614751060372,'') 'post', ifnull(dropdown1614742750833,'') 'type', ifnull(dropdown1614750342128,'') 'nature', ifnull(text1614742995718,'') 'corporation', ifnull(dropdown1614750626613,'') 'pay_method', ifnull(ShortText1617870922867,0) 'paydays', ifnull(number1614751108814,'') 'mobile', ifnull(ShortText1617870495099,'') 'address', ifnull(dropdown1614750757071,'') 'return_ticket', ifnull(dropdown1614751201116,'') 'delivery', 1 'status', createdTime 'addtime', modifiedTime 'updatetime'")->select()->toArray(); return $data; } }