当前位置: 首页>>代码示例>>PHP>>正文


PHP Country::save方法代码示例

本文整理汇总了PHP中app\models\Country::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::save方法的具体用法?PHP Country::save怎么用?PHP Country::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Country的用法示例。


在下文中一共展示了Country::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Создание контента
  * @return string
  */
 public function actionCreate()
 {
     $model = new Country();
     $uploadImg = new UploadForm();
     if (Yii::$app->request->isPost) {
         $uploadImg->img = UploadedFile::getInstance($uploadImg, 'img');
         if ($uploadImg->img && $uploadImg->validate()) {
             $uploadImg->img->saveAs('uploads/icoflags/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension);
         } else {
             print_r($uploadImg->getErrors());
         }
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->name = Yii::$app->request->post('Country')['name'];
         $model->iso_code = Yii::$app->request->post('Country')['iso_code'];
         $model->soc_abrev = Yii::$app->request->post('Country')['soc_abrev'];
         $model->soccer_code = Yii::$app->request->post('Country')['soccer_code'];
         if (isset($uploadImg->img)) {
             $model->icon = Url::base() . 'uploads/icoflags/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension;
         }
         $model->save(false);
         return $this->redirect(Url::toRoute('countries/index'));
     } else {
         return $this->render('_form', ['model' => $model, 'uploadImg' => $uploadImg]);
     }
 }
开发者ID:roman1970,项目名称:lis,代码行数:30,代码来源:CountriesController.php

示例2: actionCreate

 /**
  * Creates a new Country model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Country();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->country_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:vab777,项目名称:marts.id_be,代码行数:14,代码来源:CountryController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name_en' => 'required', 'name_cn' => 'required', 'call_code' => 'required']);
     $model = new Country();
     $model->name_en = $request->name_en;
     $model->name_cn = $request->name_cn;
     $model->short = $request->short;
     $model->call_code = $request->call_code;
     $model->active = $request->active ? 1 : 0;
     $model->save();
 }
开发者ID:valleyblvd,项目名称:YueFang-ops-web,代码行数:17,代码来源:CountryController.php

示例4: save

 public function save($request)
 {
     $country = new Country();
     $country->country_name = $request->input('country_name');
     $country->country_code = $request->input('country_code');
     $country->currency = $request->input('currency');
     $country->status = $request->input('status');
     if ($country->save()) {
         return $country->id;
     } else {
         return false;
     }
 }
开发者ID:iqbalmalik89,项目名称:carpool,代码行数:13,代码来源:CountryRepository.php

示例5: actionUpdate

 /**
  * Updates an existing Country model.
  * If update is successful, the browser will be redirected to the 'update' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id = null)
 {
     if ($id) {
         $model = $this->findModel($id);
     } else {
         $model = new Country();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', __('Your changes have been saved successfully.'));
         return $this->redirect(['index']);
     } else {
         return $this->renderAjax('update', ['model' => $model]);
     }
 }
开发者ID:vsguts,项目名称:crm,代码行数:20,代码来源:CountryController.php

示例6: testCreateModel

 public function testCreateModel()
 {
     $indonesia = new Country(array('name' => 'Indonesia'));
     $indonesia->save();
     $user = new User(array('fullname' => 'Mukhamad Ikhsan', 'email' => 'some.email@email.com', 'password' => 'rahasia', 'profile' => array('profession' => 'programmer', 'nationality' => $indonesia)));
     $this->assertEqual('Mukhamad Ikhsan', $user->fullname);
     $this->assertEqual('programmer', $user->profile->profession);
     $this->assertEqual('Indonesia', $user->profile->nationality->name);
     $this->assertTrue($user->save());
     $ikhsan = User::getRepository()->findOneBy(array('email' => 'some.email@email.com'));
     $users = User::findAll(array('where' => array('and' => array(array('fullname' => array('like' => '%Ikhsan')), array('fullname' => array('eq' => 'Mukhamad Ikhsan')), array('fullname' => array('neq' => 'Haris Riswandi')))), 'leftJoin' => array(array('field' => 'groups'))));
     $compacts = User::getCompactList('fullname');
     $this->assertEqual(1, count($users));
     $this->assertEqual(1, count($compacts));
     $this->assertEqual('Mukhamad Ikhsan', $ikhsan->fullname);
     $this->assertEqual('programmer', $ikhsan->profile->profession);
     $this->assertEqual('Indonesia', $ikhsan->profile->nationality->name);
     $ikhsan->delete();
     $indonesia->delete();
     $this->assertNull(User::getRepository()->findOneBy(array('email' => 'some.email@email.com')));
     $this->assertNull(Country::getRepository()->findOneBy(array('name' => 'Indonesia')));
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:22,代码来源:ModelTest.php

示例7: actionGetCountriesFromYndex

 public function actionGetCountriesFromYndex()
 {
     $url = "https://pogoda.yandex.ru/static/cities.xml";
     $dom = new \DomDocument();
     $dom->load($url);
     $countries = $dom->getElementsByTagName("country");
     foreach ($countries as $country) {
         $newCountry = new Country();
         $newCountry->name = $country->getAttribute('name');
         $newCountry->save(false);
     }
 }
开发者ID:roman1970,项目名称:lis,代码行数:12,代码来源:WeatherController.php


注:本文中的app\models\Country::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。