public function actionCitychainstatus() { \yii::$app->user->setIdentity(\common\models\User::findByUsername('admin')); $usersData = \yii::$app->oldcmsdb->createCommand("SELECT * \n FROM \n tc_group_field_status_mapping")->query(); while ($row = $usersData->read()) { $attributes = array('Id' => $row['id'], 'chainCityMapid' => $row['chain_city_id'], 'name' => $row['establishment_name'], 'website' => $row['establishment_website'], 'pricefortwo' => $row['price_for_two'], 'cusinies' => $row['cusinies'], 'specilities' => $row['specilites'], 'whichType' => $row['est_which_type'], 'crowd' => $row['crowd'], 'type' => $row['establishment_type'], 'facebookUrl' => $row['facebook_url'], 'serves' => $row['serves'], 'createdBy' => 40, 'updatedBy' => 40, 'createdOn' => $row['insert_date'], 'updatedOn' => $row['modified_date'], 'status' => 1); if (($brand = BrandsCityFieldStatusMap::findOne($attributes['Id'])) !== null) { } else { $brand = new BrandsCityFieldStatusMap(); } $brand->detachBehavior('timestamp'); $brand->detachBehavior('user'); $brand->setAttributes($attributes); $brand->Id = $attributes['Id']; if ($brand->save(false)) { echo "Map Id:" . $attributes['chainCityMapid'] . ": imported\n"; } else { echo "Map Id:" . $attributes['chainCityMapid'] . ": not imported\n"; } } }
protected function findMapModel($id) { if (($model = BrandsCityFieldStatusMap::findOne(['chainCityMapid' => $id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }