本文整理汇总了PHP中app\models\City::find方法的典型用法代码示例。如果您正苦于以下问题:PHP City::find方法的具体用法?PHP City::find怎么用?PHP City::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\City
的用法示例。
在下文中一共展示了City::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Lists all City models.
* @return mixed
*/
public function actionIndex()
{
//$params=Yii::$app->request->get();
$params = $_REQUEST;
$filter = array();
$sort = "";
$page = 1;
$limit = 5;
if (isset($params['page'])) {
$page = $params['page'];
unset($params['page']);
}
if (isset($params['limit'])) {
$limit = $params['limit'];
unset($params['limit']);
}
$offset = $limit * ($page - 1);
if (isset($params['filter'])) {
$filter = (array) json_decode($params['filter']);
}
if (isset($params['sort'])) {
$sort = $params['sort'];
}
$models = City::find()->offset($offset)->limit($limit)->where($filter)->orderBy($sort)->all();
$totalItems = City::find()->count();
$data = array();
foreach ($models as $m) {
$data[] = $m->attributes;
}
$this->getHeader(200);
echo json_encode(array('status' => 1, 'data' => $data, 'totalItems' => $totalItems), JSON_PRETTY_PRINT);
}
示例2: actionDeliveryCost
public function actionDeliveryCost($code)
{
//check the api for the returned data
//check country
$city = City::find()->where('Name="' . $code . '"')->one();
//var_dump($city);
if ($city->CountryCode == 'EGY') {
//calculate weight
$sum = 0;
foreach (Shopcart::goods() as $good) {
$sum += $good->item->product_weight;
}
// return "the new cost--".$city->Name .$city->CountryCode;
//$city->CountryCode;
$cost = $this->GetCost($city->Name, $sum);
if ($cost == '' or $cost == 0) {
return Setting::get('deliver_cost');
} else {
return $cost;
}
} else {
return Setting::get('deliver_cost');
//.'-99'. $city->CountryCode;
}
}
示例3: actionIndex
public function actionIndex($mid = '', $f = 0)
{
$user = User::findIdentity(Yii::$app->user->id);
$regFrm = new RegisterForm();
$rstFrm = new RestorePswForm();
$spOffs = new SpecialOffer();
$spOffs = $spOffs->getAllSpecialOffers();
if ($f) {
$logFrm = new LoginForm(['scenario' => LoginForm::SCENARIO_LOGIN_CAPTCHA]);
} else {
$logFrm = new LoginForm(['scenario' => LoginForm::SCENARIO_LOGIN]);
}
$city = City::find()->all();
$address = new Address();
$distr = $address->getDistrict();
$category = Category::find()->all();
$brand = Brand::find()->all();
$msg = '';
switch ($mid) {
case 1:
$msg = Common::M_EMAIL_SEND;
break;
case 2:
$msg = Common::M_PSW_EMAIL_SEND;
break;
case 3:
$msg = Common::M_PSW_RESTORE_SUCCESS;
break;
}
return $this->render('index', ['msg' => $msg, 'user' => $user, 'spOffs' => $spOffs, 'regFrm' => $regFrm, 'logFrm' => $logFrm, 'rstFrm' => $rstFrm, 'city' => $city, 'distr' => $distr, 'category' => $category, 'brand' => $brand]);
}
示例4: actionGetorgcity
public function actionGetorgcity($id)
{
$rows = \app\models\City::find()->where(['state_id' => $id, 'is_status' => 0])->ALL();
echo Html::tag('option', Html::encode(Yii::t('app', '--- Select City ---')), ['value' => '']);
foreach ($rows as $row) {
echo Html::tag('option', Html::encode($row->city_name), ['value' => $row->city_id]);
}
}
示例5: actionIndex
/**
* Lists all Locale models.
* @return mixed
*/
public function actionIndex()
{
// $searchModel = new LocaleSearch();
// $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$this->layout = 'main2';
$model = City::find()->all();
return $this->render('index', ['model' => $model]);
}
示例6: actionGetRegionCities
public function actionGetRegionCities($region_id)
{
$cities = \app\models\City::find()->where(['region_id' => $region_id])->all();
$content = '';
foreach ($cities as $city) {
$content .= '<option value="' . $city->id . '">' . $city->title . '</option>';
}
return $content;
}
示例7: selectLocation
/**
* @todo Save location by session
*
* @param \Illuminate\Http\Request $request
* @param int $id City id
*
* @return Redirect
*/
public function selectLocation($id)
{
$id = (int) $id;
if (!is_null(City::find($id))) {
Session::put(_const('SESSION_LOCATION'), $id);
Session::save();
}
return redirect(route('front_home'));
}
示例8: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = City::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'region_id' => $this->region_id, 'region_global_id' => $this->region_global_id, 'gmt' => $this->gmt, 'sort_id' => $this->sort_id, 'old_region_id' => $this->old_region_id, 'is_deleted' => $this->is_deleted, 'is_published' => $this->is_published, 'timezone' => $this->timezone]);
$query->andFilterWhere(['like', 'id_1c', $this->id_1c])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'region_1c', $this->region_1c])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'title_1c', $this->title_1c])->andFilterWhere(['like', 'geoip_city', $this->geoip_city])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'alternative_path', $this->alternative_path])->andFilterWhere(['like', 'old_path', $this->old_path])->andFilterWhere(['like', 'service_center', $this->service_center])->andFilterWhere(['like', 'manufacturer_service_center', $this->manufacturer_service_center])->andFilterWhere(['like', 'yandex_confirm_code', $this->yandex_confirm_code])->andFilterWhere(['like', 'yandex_confirm_code_tp', $this->yandex_confirm_code_tp])->andFilterWhere(['like', 'yandex_confirm_code_bazar', $this->yandex_confirm_code_bazar]);
return $dataProvider;
}
示例9: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = City::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'createdAt' => $this->createdAt, 'updatedAt' => $this->updatedAt]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
示例10: actionEmp_p_city
public function actionEmp_p_city($id)
{
$rows = \app\models\City::find()->where(['city_state_id' => $id, 'is_status' => 0])->all();
echo "<option value=''>---Select City---</option>";
if (count($rows) > 0) {
foreach ($rows as $row) {
echo "<option value='{$row->city_id}'>{$row->city_name}</option>";
}
} else {
echo "";
}
}
示例11: actionFillTeams
public function actionFillTeams()
{
foreach ($this->arrOfTeams as $team => $city) {
$model = new Khlteams();
$model->name = $team;
$city_id = City::find()->where("name like('" . $city . "')")->one()->id;
if (!$city_id) {
$city_id = 1513;
}
$model->city_id = $city_id;
$model->save(false);
}
}
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = City::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'country_id' => $this->country_id, 'state_id' => $this->state_id, 'created_by' => $this->created_by, 'modified_by' => $this->modified_by, 'created_date' => $this->created_date, 'modified_date' => $this->modified_date]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'status', $this->status]);
return $dataProvider;
}
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = City::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'have_event' => $this->have_event]);
$query->andFilterWhere(['like', 'title_uk', $this->title_uk])->andFilterWhere(['like', 'title_ru', $this->title_ru])->andFilterWhere(['like', 'title_en', $this->title_en]);
return $dataProvider;
}
示例14: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = City::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'province_id' => $this->province_id]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'citycol', $this->citycol]);
return $dataProvider;
}
示例15: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = City::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'note', $this->note]);
return $dataProvider;
}