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


PHP City::findOne方法代码示例

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


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

示例1: actionLocales

 public function actionLocales()
 {
     $model = City::findOne($_POST['id']);
     $aux = array();
     foreach ($model->locales as $k => $locale) {
         $aux[$k]['id'] = $locale->id;
         $aux[$k]['address'] = $locale->address;
     }
     echo json_encode($aux);
 }
开发者ID:frankpaul142,项目名称:chaide,代码行数:10,代码来源:LocaleController.php

示例2:

             $add_s = '';
         }
         if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_cadd_country)) {
             $add_co = Country::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_cadd_country)->country_name;
         } else {
             $add_co = '';
         }
         echo "<td class='text-center'>" . EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_cadd . " " . $add_c . " " . $add_s . " " . $add_co . "</td>";
     } else {
         echo "<td class='text-center'>&nbsp;</td>";
     }
 } else {
     if ($s == 'emp_padd') {
         if ($sd['emp_master_emp_address_id'] != 0) {
             if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_city)) {
                 $add_c = "<br/>" . City::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_city)->city_name . ", ";
             } else {
                 $add_c = '';
             }
             if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_state)) {
                 $add_s = State::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_state)->state_name . ", ";
             } else {
                 $add_s = '';
             }
             if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_country)) {
                 $add_co = Country::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_country)->country_name;
             } else {
                 $add_co = '';
             }
             echo "<td class='text-center'>" . EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd . " " . $add_c . " " . $add_s . " " . $add_co . "</td>";
         } else {
开发者ID:EduSec,项目名称:EduSec,代码行数:31,代码来源:emp_info_report.php

示例3: actionGetStations

 function actionGetStations()
 {
     $id_city = $this->get["id_city"];
     $city = City::findOne(['id' => $id_city]);
     if (count($city) == 0) {
         $r = $this->setError(150);
     } else {
         $stations = Stations::find()->where("id_city='" . $id_city . "' ")->asArray()->all();
         $r["status"] = "ok";
         $r["stations"] = $stations;
     }
     return json_encode($r);
 }
开发者ID:kidskazan,项目名称:masterslavl,代码行数:13,代码来源:ApiController.php

示例4:

         }
         if (!empty(StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd_country)) {
             $add_co = Country::findOne(StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd_country)->country_name;
         } else {
             $add_co = '';
         }
         echo "<td style='text-align:center; width:400px;'>" . StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd . $add_city_c . " " . $add_s . " " . $add_co . "</td>";
     } else {
         echo "<td>&nbsp;</td>";
     }
 } else {
     if ($s == 'city') {
         if ($sd['stu_master_stu_address_id'] != 0) {
             $add = StuAddress::findOne($sd['stu_master_stu_address_id']);
             if (!empty($add)) {
                 $city = City::findOne($add->stu_cadd_city);
             }
             if (!empty($add->stu_cadd_city)) {
                 echo "<td style='text-align:center;'>" . $city['city_name'] . "</td>";
             } else {
                 echo "<td>&nbsp;</td>";
             }
         } else {
             echo "<td>&nbsp;</td>";
         }
     } else {
         if ($s == 'stu_email_id') {
             if (StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} != null) {
                 echo "<td style='text-align:center;width:250px;'>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td>";
             } else {
                 echo "<td style='text-align:center;'>&nbsp;</td>";
开发者ID:aoopvn,项目名称:EduSec4.0.0,代码行数:31,代码来源:stu_info_report_excel.php

示例5: findModel

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

示例6: actionGetCoords

 public function actionGetCoords()
 {
     $data = Yii::$app->request->post();
     $cityID = $data['city'];
     $city = City::findOne($cityID);
     $cityName = null;
     if ($city) {
         $cityName = $city->name;
     }
     $address = Address::find()->andFilterWhere(['city' => $cityName])->asArray()->all();
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $responce = ['coords' => $address];
     return $responce;
 }
开发者ID:Bibihelper,项目名称:Project2015,代码行数:14,代码来源:IndexController.php

示例7: getCountKidsCity

 public function getCountKidsCity()
 {
     $city = City::findOne($this->id_city);
     return $city->count_kids;
 }
开发者ID:kidskazan,项目名称:masterslavl,代码行数:5,代码来源:generalState.php

示例8:

         if (!empty(StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd_country)) {
             $add_co = Country::findOne(StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd_country)->country_name;
         } else {
             $add_co = '';
         }
         echo "<td >" . StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd . " " . $add_city_c . " " . $add_s . " " . $add_co . "</td></tr>";
     } else {
         echo "<td>&nbsp;</td></tr>";
     }
 } else {
     if ($s == 'city') {
         echo "<tr><td class='label'>" . Yii::t('report', 'City') . "</td>";
         if ($sd['stu_master_stu_address_id'] != 0) {
             $add = StuAddress::findOne($sd['stu_master_stu_address_id']);
             if ($add->stu_cadd_city != null) {
                 echo "<td>" . (!empty(City::findOne($add->stu_cadd_city)->city_name) ? City::findOne($add->stu_cadd_city)->city_name : " Not Set ") . "</td></tr>";
             } else {
                 echo "<td>&nbsp;</td></tr>";
             }
         } else {
             echo "<td>&nbsp;</td></tr>";
         }
     } else {
         if ($s == 'stu_email_id') {
             if (StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} != null) {
                 echo "<tr><td class='label'>" . Yii::t('report', 'Email Id') . "</td> <td>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td> </tr>";
             } else {
                 echo "<tr><td class='label'>" . Yii::t('report', 'Email ID') . "</td> <td >&nbsp;</td></tr>";
             }
         } else {
             if ($s == 'stu_admission_date') {
开发者ID:EduSec,项目名称:EduSec,代码行数:31,代码来源:stu_info_report_pdf.php

示例9:

     }
 } else {
     if ($s == 'emp_category_name') {
         echo "<tr><td class='label'>Category Name </td>";
         if ($sd['emp_master_category_id'] != 0) {
             echo "<td>" . Category::findOne($sd['emp_master_category_id'])->emp_category_name . "</td></tr>";
         } else {
             echo "<td>&nbsp;</td></tr>";
         }
     } else {
         if ($s == 'city') {
             echo "<tr><td class='label'>City</td>";
             if ($sd['emp_master_emp_address_id'] != 0) {
                 $add = EmpAddress::findOne($sd['emp_master_emp_address_id']);
                 if ($add->emp_cadd_city != null) {
                     echo "<td>" . City::findOne($add->emp_cadd_city)->city_name . "</td></tr>";
                 } else {
                     echo "<td>&nbsp;</td></tr>";
                 }
             } else {
                 echo "<td>&nbsp;</td></tr>";
             }
         } else {
             if ($s == 'emp_guardian_mobile_no') {
                 echo "<tr><td class='label'>Guardian No </td>";
                 echo "<td>" . $sd[$s] . "</td></tr>";
             } else {
                 if ($s == 'emp_bloodgroup') {
                     echo "<tr><td class='label'>Blood Group</td><td>" . $sd[$s] . "</td></tr>";
                 } else {
                     echo "<tr><td class='label'>" . Html::ActiveLabel($emp_info, $s) . " </td><td>" . $sd[$s] . "</td></tr>";
开发者ID:aoopvn,项目名称:EduSec4.0.0,代码行数:31,代码来源:emp_info_report_pdf.php

示例10: findModel

 /**
  * Finds the City model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return City the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = City::findOne($id)) !== null) {
         return $model;
     } else {
         $this->getHeader(400);
         echo json_encode(array('status' => 0, 'error_code' => 400, 'message' => 'Bad request'), JSON_PRETTY_PRINT);
         exit;
         // throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:tejrajs,项目名称:yii2RestAPI,代码行数:18,代码来源:CityController.php

示例11: getCityName

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

示例12: actionGetYandexWeather

 public function actionGetYandexWeather()
 {
     foreach ($this->cities as $city) {
         $cityIn = City::findOne(['name' => $city]);
         $url = 'http://export.yandex.ru/weather-ng/forecasts/' . $cityIn->yndid . '.xml';
         //$url =  'http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=1a415db9cc13a7d753bcc5fc25ee5972';
         //echo $url; exit;
         try {
             $xml = simplexml_load_file($url);
         } catch (\ErrorException $e) {
             echo $e->getMessage();
             continue;
         }
         $this->temp = $xml->fact->temperature;
         $this->weather_type = $xml->fact->weather_type;
         $this->wind_direction = $xml->fact->wind_direction;
         $this->wind_speed = $xml->fact->wind_speed;
         $this->humidity = $xml->fact->humidity;
         $this->pressure = $xml->fact->pressure;
         $this->cityId = $cityIn->id;
         $this->putDatasInTableNew();
     }
 }
开发者ID:roman1970,项目名称:lis,代码行数:23,代码来源:WeatherController.php

示例13: getSrchRes

 public function getSrchRes($city = null, $brand = null, $service = null, $district = null, $name = null, $address = null, $twfhr = null)
 {
     $cityObj = City::findOne($city);
     if ($address) {
         $a1 = str_replace(' ', ',', trim($address));
         $a2 = explode(',', $a1);
         if ($a2) {
             $a4 = [];
             foreach ($a2 as $a3) {
                 if (mb_strlen($a3, 'UTF-8') > 4) {
                     $a4[] = $a3;
                 }
             }
             if (count($a4) > 0) {
                 $a5 = implode('%', $a4);
                 $address = $a5;
             }
         }
     }
     $srchres = $this->find()->select(['company.id', 'company.name', 'company.phone', 'company.twenty_four_hours', 'address.city', 'address.district', 'address.street', 'address.home', 'address.housing', 'address.building', 'address.latitude', 'address.longitude', 'special_offer.id AS special_offer_id', 'company_brands.id AS company_brands_id', 'company_services.id AS company_services_id'])->leftJoin('address', '`address`.`id` = `company`.`address_id`')->leftJoin('special_offer', '`special_offer`.`company_id` = `company`.`id`')->leftJoin('company_brands', '`company_brands`.`company_id` = `company`.`id`')->leftJoin('company_services', '`company_services`.`company_id` = `company`.`id`')->filterWhere(['company_brands.brand_id' => $brand, 'company_services.service_id' => $service, 'address.city' => $cityObj['name'], 'address.district' => $district, 'company.name' => $name, 'company.twenty_four_hours' => $twfhr])->andFilterWhere(['like', 'address.street', $address])->asArray()->all();
     $id = ArrayHelper::getColumn($srchres, 'id');
     $shedule = Shedule::find()->where(['company_id' => $id])->asArray()->all();
     $shedule2 = [];
     foreach ($shedule as $sh) {
         $companyID = $sh['company_id'];
         $shedule2[$companyID][] = $sh;
     }
     for ($i = 0; $i < count($srchres); $i++) {
         $companyID = $srchres[$i]['id'];
         $srchres[$i]['shedule'] = $shedule2[$companyID];
     }
     return $srchres;
 }
开发者ID:Bibihelper,项目名称:Project2015,代码行数:33,代码来源:Company.php


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