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


PHP Region::findOne方法代码示例

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


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

示例1: up

 public function up()
 {
     $this->createTable('splatfest', ['id' => $this->primaryKey(), 'region_id' => $this->integer()->notNull(), 'name' => $this->string(64)->notNull(), 'start_at' => 'TIMESTAMP(0) WITH TIME ZONE NOT NULL', 'end_at' => 'TIMESTAMP(0) WITH TIME ZONE NOT NULL']);
     $this->addForeignKey('fk_splatfest_1', 'splatfest', 'region_id', 'region', 'id');
     $jp = Region::findOne(['key' => 'jp'])->id;
     $this->batchInsert('splatfest', ['region_id', 'name', 'start_at', 'end_at'], [[$jp, 'ごはん vs パン', '2015-06-13 18:00:00+09', '2015-06-14 18:00:00+09'], [$jp, '赤いきつね vs 緑のたぬき', '2015-07-03 15:00:00+09', '2015-07-04 15:00:00+09'], [$jp, 'レモンティー vs ミルクティー', '2015-07-25 15:00:00+09', '2015-07-26 15:00:00+09'], [$jp, 'キリギリス vs アリ', '2015-08-22 12:00:00+09', '2015-08-23 12:00:00+09'], [$jp, 'ボケ vs ツッコミ', '2015-09-12 12:00:00+09', '2015-09-13 12:00:00+09'], [$jp, 'イカ vs タコ', '2015-10-10 09:00:00+09', '2015-10-11 09:00:00+09'], [$jp, '愛 vs おカネ', '2015-10-31 09:00:00+09', '2015-11-01 09:00:00+09'], [$jp, '山の幸 vs 海の幸', '2015-11-21 12:00:00+09', '2015-11-22 12:00:00+09'], [$jp, '赤いきつね vs 緑のたぬき', '2015-12-26 09:00:00+09', '2015-12-27 09:00:00+09']]);
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:7,代码来源:m151219_093250_splatfest.php

示例2: actionUpdate

 public function actionUpdate($region, $number)
 {
     $transaction = Yii::$app->db->beginTransaction();
     if (!($region = Region::findOne(['key' => $region]))) {
         printf("Unknown region: %s\n", $region);
         return 1;
     }
     if (!($fest = Splatfest::findOne(['region_id' => $region->id, '[[order]]' => $number]))) {
         printf("Unknown number: %s (region = %s)\n", $number, $region->key);
         return 1;
     }
     printf("Target #%d (Region=%s, Number=%d)\n", $fest->id, $region->key, $fest->order);
     $alpha = SplatfestTeam::findOne(['fest_id' => $fest->id, 'team_id' => 1]);
     $bravo = SplatfestTeam::findOne(['fest_id' => $fest->id, 'team_id' => 2]);
     if (!$alpha || !$bravo || $alpha->color_hue === null || $bravo->color_hue === null) {
         printf("    > Team information is not ready\n");
         return 1;
     }
     printf("    > cleanup ...\n");
     SplatfestBattleSummary::deleteAll(['fest_id' => $fest->id]);
     $this->createBattleSummaryTmpTimestamp($fest);
     $this->createBattleSummaryTmpTable('tmp_summary_a', $fest, $alpha->color_hue, $bravo->color_hue);
     $this->createBattleSummaryTmpTable('tmp_summary_b', $fest, $bravo->color_hue, $alpha->color_hue);
     $this->createBattleSummary($fest);
     $transaction->commit();
     return 0;
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:27,代码来源:SplatfestController.php

示例3: safeUp

 public function safeUp()
 {
     $regionNA = Region::findOne(['key' => 'na'])->id;
     $this->batchInsert('timezone', ['identifier', 'name', 'order', 'region_id'], [['America/St_Johns', 'North America (Newfoundland)', 10001, $regionNA], ['America/Halifax', 'North America (AT)', 10002, $regionNA], ['America/Regina', 'North America (Saskatchewan)', 10003, $regionNA]]);
     $newOrder = ['America/St_Johns', 'America/Halifax', 'America/New_York', 'America/Chicago', 'America/Regina', 'America/Denver', 'America/Phoenix', 'America/Los_Angeles', 'America/Anchorage', 'America/Adak', 'Pacific/Honolulu'];
     $order = 20 + count($newOrder);
     foreach (array_reverse($newOrder) as $ident) {
         $this->update('timezone', ['order' => $order--], ['identifier' => $ident]);
     }
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:10,代码来源:m160108_135055_tz.php

示例4: actionDeleteRegion

 public function actionDeleteRegion($region_id, $user_id)
 {
     $user = User::findOne($user_id);
     $region = Region::findOne($region_id);
     if (!$user) {
         throw new NotFoundHttpException('Данный пользователь не существует.');
     }
     $user->unlinkRegion($region_id);
     $user->save();
 }
开发者ID:igribov,项目名称:question-list,代码行数:10,代码来源:UserLinkedOfficesRegionsController.php

示例5: up

 public function up()
 {
     $this->createTable('team', ['id' => 'INTEGER NOT NULL PRIMARY KEY', 'name' => 'VARCHAR(8) NOT NULL', 'leader' => 'VARCHAR(8) NOT NULL']);
     $this->batchInsert('team', ['id', 'name', 'leader'], [[1, 'Alpha', 'Callie'], [2, 'Bravo', 'Marie']]);
     $this->createTable('splatfest_team', ['fest_id' => 'INTEGER NOT NULL', 'team_id' => 'INTEGER NOT NULL', 'name' => 'VARCHAR(32) NOT NULL', 'color_hue' => 'INTEGER NULL']);
     $this->addPrimaryKey('pk_splatfest_team', 'splatfest_team', ['fest_id', 'team_id']);
     $this->addForeignKey('fk_splatfest_team_1', 'splatfest_team', 'fest_id', 'splatfest', 'id');
     $this->addForeignKey('fk_splatfest_team_2', 'splatfest_team', 'team_id', 'team', 'id');
     $jp = Region::findOne(['key' => 'jp'])->id;
     $this->batchInsert('splatfest_team', ['fest_id', 'team_id', 'name', 'color_hue'], [[$this->fest($jp, 7), 1, '愛', 332], [$this->fest($jp, 7), 2, 'おカネ', 34], [$this->fest($jp, 8), 1, '山の幸', 346], [$this->fest($jp, 8), 2, '海の幸', 166], [$this->fest($jp, 9), 1, '赤いきつね', 335], [$this->fest($jp, 9), 2, '緑のたぬき', 155]]);
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:11,代码来源:m151223_123831_splatfest_team.php

示例6: up

 public function up()
 {
     $this->execute('ALTER TABLE {{timezone}} ADD COLUMN [[region_id]] INTEGER');
     $this->addForeignKey('fk_timezone_1', 'timezone', 'region_id', 'region', 'id');
     // Japan
     $this->update('timezone', ['region_id' => Region::findOne(['key' => 'jp'])->id], ['identifier' => 'Asia/Tokyo']);
     // Europe/Oceania
     $this->update('timezone', ['region_id' => Region::findOne(['key' => 'eu'])->id], ['or like', 'identifier', ['Etc/UTC', 'Europe/%', 'Australia/%'], false]);
     // North America
     $this->update('timezone', ['region_id' => Region::findOne(['key' => 'na'])->id], ['or like', 'identifier', ['America/%', 'Pacific/Honolulu'], false]);
     $this->execute('ALTER TABLE {{timezone}} ALTER COLUMN [[region_id]] SET NOT NULL');
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:12,代码来源:m151219_091018_timezone_region.php

示例7: up

 public function up()
 {
     $this->execute('ALTER TABLE {{splatfest}} ADD COLUMN [[order]] INTEGER');
     $transaction = \Yii::$app->db->beginTransaction();
     $jp = Region::findOne(['key' => 'jp'])->id;
     $jpStarts = ['2015-06-13 18:00:00+09', '2015-07-03 15:00:00+09', '2015-07-25 15:00:00+09', '2015-08-22 12:00:00+09', '2015-09-12 12:00:00+09', '2015-10-10 09:00:00+09', '2015-10-31 09:00:00+09', '2015-11-21 12:00:00+09', '2015-12-26 09:00:00+09'];
     foreach ($jpStarts as $i => $startAt) {
         $this->update('splatfest', ['order' => $i + 1], ['region_id' => $jp, 'start_at' => $startAt]);
     }
     $transaction->commit();
     $this->execute('ALTER TABLE {{splatfest}} ALTER COLUMN [[order]] SET NOT NULL');
     $this->createIndex('ix_splatfest_1', 'splatfest', ['region_id', 'order'], true);
 }
开发者ID:frozenpandaman,项目名称:stat.ink,代码行数:13,代码来源:m151223_113054_splatfest_order.php

示例8: getRegionName

 public function getRegionName()
 {
     return Region::findOne(['id' => $this->region_id])->title;
 }
开发者ID:islamham,项目名称:125ent,代码行数:4,代码来源:City.php

示例9: findModel

 /**
  * Finds the Region model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Region the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Region::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:pdbangibang,项目名称:apc-softdev-gd121mi122-4,代码行数:15,代码来源:RegionController.php

示例10: actionMapa

 public function actionMapa($location_id)
 {
     $location = \app\models\Region::findOne($location_id);
     $places = Place::find(['location_id' => $location_id])->all();
     return $this->render('mapa', ['location' => $location, 'places' => $places]);
 }
开发者ID:pachopascolat,项目名称:turismoYii,代码行数:6,代码来源:PlaceController.php

示例11: actionExample

 public function actionExample()
 {
     $UrRecords = Ur::findOne(1);
     $RegionRecords = [Region::findOne(2), Region::findOne(3)];
     $extraColumns = [];
     // extra columns to be saved to the many to many table
     $unlink = true;
     // unlink tags not in the list
     $delete = true;
     // delete unlinked tags
     $UrRecords->linkAll('RegionRecords', $RegionRecords, $extraColumns, $unlink, $delete);
     $UrRecords->save();
     // var_dump($UrRecords);
     // exit;
 }
开发者ID:pumi11,项目名称:aau,代码行数:15,代码来源:UrController.php


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