/** * Execute the console command. * * @return mixed */ public function fire() { ini_set('max_execution_time', 0); $answers = Answer::whereNotNull('id_attribute')->get(); Answer::whereRaw('1=1')->update(['id_attr_map' => null]); $oldAnswers = DB::connection('old')->select('select * from option_ans where attribute_id is not null'); foreach ($answers as $answer) { foreach ($oldAnswers as $oldAnswer) { if (strcmp($answer->name, $oldAnswer->opt_content) == 0) { $data = DB::connection('old')->select('select * from attribute where id = ' . $oldAnswer->attribute_id); $answer->id_attr_map = $data[0]->attribute; $answer->save(); echo $answer->name . "\n"; echo $oldAnswer->opt_content . "\n"; echo $answer->id_attr_map . "\n"; echo "---------\n"; break; } } } }