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


PHP Region::save方法代码示例

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


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

示例1: actionCreate

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

示例2: createRegion

 public function createRegion($name, $attr = [])
 {
     if (!($model = $this->findRegion($name))) {
         $model = new Region();
         $model->name = $name;
         $model->setAttributes($attr);
         $model->save(false);
     }
     return $model;
 }
开发者ID:carono,项目名称:yii2-components,代码行数:10,代码来源:CityController.php

示例3: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $client = new HttpClient();
     $provinces = json_decode('[{"children":[],"diji":"","quHuaDaiMa":"110000","quhao":"","shengji":"北京市(京)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"120000","quhao":"","shengji":"天津市(津)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"130000","quhao":"","shengji":"河北省(冀)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"140000","quhao":"","shengji":"山西省(晋)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"150000","quhao":"","shengji":"内蒙古自治区(内蒙古)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"210000","quhao":"","shengji":"辽宁省(辽)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"220000","quhao":"","shengji":"吉林省(吉)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"230000","quhao":"","shengji":"黑龙江省(黑)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"310000","quhao":"","shengji":"上海市(沪)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"320000","quhao":"","shengji":"江苏省(苏)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"330000","quhao":"","shengji":"浙江省(浙)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"340000","quhao":"","shengji":"安徽省(皖)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"350000","quhao":"","shengji":"福建省(闽)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"360000","quhao":"","shengji":"江西省(赣)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"370000","quhao":"","shengji":"山东省(鲁)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"410000","quhao":"","shengji":"河南省(豫)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"420000","quhao":"","shengji":"湖北省(鄂)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"430000","quhao":"","shengji":"湖南省(湘)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"440000","quhao":"","shengji":"广东省(粤)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"450000","quhao":"","shengji":"广西壮族自治区(桂)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"460000","quhao":"","shengji":"海南省(琼)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"500000","quhao":"","shengji":"重庆市(渝)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"510000","quhao":"","shengji":"四川省(川、蜀)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"520000","quhao":"","shengji":"贵州省(黔、贵)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"530000","quhao":"","shengji":"云南省(滇、云)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"540000","quhao":"","shengji":"西藏自治区(藏)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"610000","quhao":"","shengji":"陕西省(陕、秦)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"620000","quhao":"","shengji":"甘肃省(甘、陇)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"630000","quhao":"","shengji":"青海省(青)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"640000","quhao":"","shengji":"宁夏回族自治区(宁)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"650000","quhao":"","shengji":"新疆维吾尔自治区(新)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"810000","quhao":"0852","shengji":"香港特别行政区(港)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"820000","quhao":"0853","shengji":"澳门特别行政区(澳)","xianji":""},{"children":[],"diji":"","quHuaDaiMa":"710000","quhao":"","shengji":"台湾省(台)","xianji":""}]', true);
     foreach ($provinces as $province) {
         preg_match_all('/(.*?)\\((.*?)\\)/', $province['shengji'], $matched);
         $region = new Region(array('region_name' => $matched[1][0], 'region_code' => $province['quHuaDaiMa'], 'parent_id' => 0, 'extra_attrs' => array('shortened' => $matched[2][0])));
         $region->save();
         echo $region->region_name . "...\r\n";
         $cities = json_decode($client->post('http://202.108.98.30/selectJson', array('headers' => ['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8'], 'body' => 'shengji=' . $province['shengji']))->getBody()->read(10240000), true);
         foreach ($cities as $c) {
             $city = new Region(array('region_name' => $c['diji'], 'region_code' => $c['quHuaDaiMa']));
             $city = $region->children()->save($city);
             $dists = json_decode($client->post('http://202.108.98.30/selectJson', array('headers' => ['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8'], 'body' => 'shengji=' . $province['shengji'] . '&diji=' . $c['diji']))->getBody()->read(10240000), true);
             foreach ($dists as $d) {
                 $dist = new Region(array('region_name' => $d['xianji'], 'region_code' => $d['quHuaDaiMa'], 'extra_attrs' => array('area_code' => $d['quhao'])));
                 $city->children()->save($dist);
             }
         }
     }
     echo 'done';
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:27,代码来源:ToolCommand.php


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