'长春市', 'parentid' => 220000, 'level' => 2])->first(); if ($city) { $aaa = \app\common\models\Address::where(['areaname' => '经开区', 'parentid'=> $city->id, 'level' => 3])->first(); if(is_null($aaa)) { \app\common\models\Address::insert(['areaname' => '经开区', 'parentid'=> $city->id, 'level' => 3]); } } } } /** * Reverse the migrations. * * @return void */ public function down() { // } }