本文整理汇总了PHP中Area::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Area::model方法的具体用法?PHP Area::model怎么用?PHP Area::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Area
的用法示例。
在下文中一共展示了Area::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionView
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$criteria = new CDbCriteria();
$criteria->condition = 'zone_id=' . $id;
$area = new CActiveDataProvider(Area::model(), array('criteria' => $criteria));
$this->render('view', array('model' => $this->loadModel($id), 'area' => $area));
}
示例2: actionGet_route
public function actionGet_route()
{
$criteria = new CDbCriteria();
$criteria->limit = 8;
$area = Area::model()->findAll($criteria);
$html = '<ul class="local_trip_pro" id="local_trip_content_list" data-blockid="recommend_localjoin">';
for ($j = 0; $j < count($area); $j++) {
if ($j) {
$html .= '<li class="local_trip_pro_li wq_clearfix hide" data-content="lj' . $j . '" style="display:none;">';
} else {
$html .= '<li class="local_trip_pro_li wq_clearfix" data-content="lj' . $j . '">';
}
$criteria1 = new CDbCriteria();
$criteria1->condition = "(style & 4) !=0";
$criteria1->addCondition('area ="' . $area[$j]->name . '"', 'AND');
$criteria1->limit = 3;
$route = Route::model()->findAll($criteria1);
for ($i = 0; $i < count($route); $i++) {
if ($i) {
$html .= '<a class="local_trip_right img_slide_animte_wrapper" href="';
} else {
$html .= '<a class="local_trip_left_l img_slide_animte_wrapper" href="';
}
if ($i) {
$html .= '#" target="_blank"> <img class="local_trip_img_s img_slide_animte first_page" src="' . $route[$i]->source . '" data-original="' . $route[$i]->source . '" style="display: block;"> <span class="local_trip_mask_s"></span> <span class="local_trip_txt_s" title="' . $route[$i]->name . '">' . $route[$i]->name . '</span>' . '<span class="local_trip_price_s font_size12"><span class="font_size16">' . $route[$i]->price . '</span>元/人起</span></a>';
} else {
$html .= '#" target="_blank"> <img class="local_trip_img_l img_slide_animte first_page" alt=" ' . $route[$i]->name . '" src="' . $route[$i]->source . '" data-original="' . $route[$i]->source . '" style="display: block;"> <span class="local_trip_mask_l"></span> <span class="local_trip_bl"></span><span class="local_trip_txt_l" title="' . $route[$i]->name . '">' . $route[$i]->name . '</span>' . '<span class="local_trip_price_l font_size14 font_color_orange"><span class="font_size28">' . $route[$i]->price . '</span>元/人起</span></a>';
}
}
$html .= '</li>';
}
$html .= '</ul>';
echo $html;
}
示例3: actionWeather
/**
* 根据地区woeid获取雅虎天气
* 获取woeid http://sugg.us.search.yahoo.net/gossip-gl-location/?appid=weather&output=xml&command=地名(如香港)
* 匹配规则:preg_match('/woeid=(\d+)\&lon=.*?\&lat=.*?\&s=.*?\&c=.*?\&country_woeid/si', $_return,$match);
* 获取天气:https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.media.weather%20where%20woeid%20in(12523356%2C90717580%2C20069923)&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=
*/
public function actionWeather()
{
ini_set('memory_limit', '256M');
ini_set('max_execution_time', '1800');
$areas = Area::model()->findAll(array('select' => 'woeid', 'condition' => 'woeid>0 AND theorder=3'));
$woeids = array_keys(CHtml::listData($areas, 'woeid', ''));
$woeidsStr = join(',', $woeids);
$dir = Yii::app()->basePath . '/runtime/weather';
$totalDir = $dir . '/total.log';
zmf::createUploadDir($dir);
$start = microtime(true);
if ($woeidsStr != '') {
$url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.media.weather%20where%20woeid%20in({$woeidsStr})&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env";
$json = zmf::curlget($url);
file_put_contents($totalDir, $json);
}
$dataArr = CJSON::decode($json, true);
$data = $dataArr['query'];
if (!$data) {
exit('Failed');
}
$results = $data['results']['result'];
$detailDir = $dir . '/detail/';
zmf::createUploadDir($detailDir);
foreach ($results as $result) {
if ($result['location']['woeid']) {
$_dir = $detailDir . $result['location']['woeid'] . '.log';
file_put_contents($_dir, CJSON::encode($result));
}
}
echo microtime(true) - $start . '--<br/>';
}
示例4: getList
public static function getList()
{
$model = Area::model();
$command = $model->getDbConnection()->CreateCommand();
$tableName = $model->tableName();
return $command->select()->from($tableName)->order('create_time DESC')->queryAll();
}
示例5: loadModel
public function loadModel($id)
{
$model = Area::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例6: getPostCode
public static function getPostCode($area)
{
if (is_numeric($area)) {
return $area;
}
$area = Area::model()->find('name=:name', array(':name' => $area));
if (is_null($area)) {
return null;
}
return $area->postcode;
}
示例7: Dynamicdistrict
public function Dynamicdistrict()
{
if ($_GET["city"]) {
$data = Area::model()->findAll("parent_id=:parent_id", array(":parent_id" => $_GET["city"]));
$data = CHtml::listData($data, "id", "name");
echo CHtml::tag("option", array("value" => ''), '请选择地区', true);
foreach ($data as $value => $name) {
echo CHtml::tag("option", array("value" => $value), CHtml::encode($name), true);
}
}
}
示例8: saveProAddress
public static function saveProAddress(UserProudctAddress $userprodaddress, $user_id)
{
$_POST['UserProudctAddress']['province'] = 'xx';
$_POST['UserProudctAddress']['city'] = 'xx';
$_POST['UserProudctAddress']['area'] = 'xx';
$_POST['UserProudctAddress']['sysaddress'] = 'xx';
if (isset($_POST['province'])) {
$_POST['UserProudctAddress']['province'] = $_POST['province'];
$provincename = Province::model()->find("provinceID=:proid", array(":proid" => $_POST['UserProudctAddress']['province']));
if ($provincename) {
$_POST['UserProudctAddress']['sysaddress'] = $provincename->province;
}
}
if (isset($_POST['city'])) {
$_POST['UserProudctAddress']['city'] = $_POST['city'];
$cityname = City::model()->find("cityID=:cityid", array(":cityid" => $_POST['UserProudctAddress']['city']));
if ($cityname) {
$_POST['UserProudctAddress']['sysaddress'] .= $cityname->city;
}
}
if (isset($_POST['area'])) {
$_POST['UserProudctAddress']['area'] = $_POST['area'];
$areaname = Area::model()->find("areaID=:areaid", array(":areaid" => $_POST['UserProudctAddress']['area']));
if ($areaname) {
$_POST['UserProudctAddress']['sysaddress'] .= $areaname->area;
}
}
$_POST['UserProudctAddress']['user_id'] = $user_id;
$userprodaddress->setAttributes($_POST['UserProudctAddress']);
foreach ((array) $_POST['UserProudctAddress'] as $key => $value) {
if (trim($value) == '') {
$userprodaddress->addError($key, "字段不能为空");
break;
}
}
if (!$userprodaddress->getErrors()) {
$userprodaddress->setAttribute('addtime', time());
$userprodaddress->setAttribute('addip', Yii::app()->request->userHostAddress);
if ($userprodaddress->validate()) {
if ($userprodaddress->isNewRecord) {
$result = $userprodaddress->save();
} else {
$result = $userprodaddress->update();
}
if (!$result) {
$userprodaddress->addError("realname", "更新失败");
}
} else {
$userprodaddress->addError("realname", "更新失败");
}
}
return $userprodaddress;
}
示例9: getarea
public static function getarea($params)
{
if ($params['p'] != 0) {
$provinceinfo = Area::model()->findByPk($params['p']);
if ($provinceinfo) {
$address .= $provinceinfo['Name'];
if ($params['c'] != 0) {
$cityinfo = Area::model()->findByPk($params['c']);
if ($cityinfo) {
$address .= ' ' . $cityinfo['Name'];
if ($params['a'] != 0) {
$areainfo = Area::model()->findByPk($params['a']);
$address .= ' ' . $areainfo['Name'];
}
}
}
}
} else {
$address = '全国';
}
return $address;
}
示例10: actionUpdateDistricts
/**
* 地区联动
*/
public function actionUpdateDistricts()
{
$areastring = "area_";
$data = Yii::app()->cache->get($areastring . (int) $_POST['idCity']);
if (!$data) {
$dataArea = Area::model()->findAll('father=:idCity', array(':idCity' => (int) $_POST['idCity']));
if (!$dataArea) {
$dataArea = City::model()->findAll('cityID=:idCity', array(':idCity' => (int) $_POST['idCity']));
if (!$dataArea) {
$dataArea = Province::model()->findAll('provinceID=:idCity', array(':idCity' => (int) $_POST['idCity']));
$data = CHtml::listData($dataArea, 'provinceID', 'province');
} else {
$data = CHtml::listData($dataArea, 'cityID', 'city');
}
} else {
$data = CHtml::listData($dataArea, 'areaID', 'area');
}
Yii::app()->cache->set($areastring . (int) $_POST['idCity'], $data);
}
echo "<option value=''>选择区域</option>";
foreach ($data as $value => $name) {
echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
}
}
示例11: run
public function run()
{
if ($area = Area::model()->findByAttributes(array('name' => $this->name))) {
if ($blocks = $area->blocks) {
if ($this->reverse) {
$blocks = array_reverse($blocks);
}
foreach ($blocks as $block) {
if ($block->view) {
$view = $block->view;
} else {
$view = $this->defaultBlockView;
}
if ($this->getViewFile($view)) {
$this->render($view, array('block' => $block));
} else {
echo $view . " - несуществующий вид блока!";
}
}
}
} else {
echo "Область вывода " . $this->name . " не найдена.";
}
}
示例12: actionGetcity
public function actionGetcity()
{
if (!Yii::app()->request->isAjaxRequest) {
exit;
}
$city = Yii::app()->request->getParam("city");
$criteria = new CDbCriteria();
$criteria->select = "ID, Name";
if (empty($city)) {
$criteria->addCondition("t.Grade = 1");
} else {
$criteria->addCondition("t.ParentID = {$city}");
$criteria->addCondition("t.Grade = 2");
}
$model = Area::model()->findAll($criteria);
$data = array();
foreach ($model as $key => $val) {
$data[$key] = array();
$data[$key]['ID'] = $val['ID'];
$data[$key]['Name'] = $val['Name'];
}
echo json_encode($data);
exit;
}
示例13: array
<?php
$state_data = Area::model()->findAll("grade=:grade", array(":grade" => 1));
$state = CHtml::listData($state_data, "id", "name");
$s_default = $model->isNewRecord ? '' : $model->state;
echo CHtml::dropDownList('AddressResult[state]', $s_default, $state, array('empty' => '请选择省份', 'ajax' => array('type' => 'GET', 'url' => CController::createUrl('dynamiccities'), 'update' => '#AddressResult_city', 'data' => 'js:"AddressResult_state="+jQuery(this).val()')));
//empty since it will be filled by the other dropdown
$c_default = $model->isNewRecord ? '' : $model->city;
if (!$model->isNewRecord) {
$city_data = Area::model()->findAll("parent_id=:parent_id", array(":parent_id" => $model->state));
$city = CHtml::listData($city_data, "id", "name");
}
$city_update = $model->isNewRecord ? array() : $city;
echo CHtml::dropDownList('AddressResult[city]', $c_default, $city_update, array('empty' => '请选择城市', 'ajax' => array('type' => 'GET', 'url' => CController::createUrl('dynamicdistrict'), 'update' => '#AddressResult_district', 'data' => 'js:"AddressResult_city="+jQuery(this).val()')));
$d_default = $model->isNewRecord ? '' : $model->district;
if (!$model->isNewRecord) {
$district_data = Area::model()->findAll("parent_id=:parent_id", array(":parent_id" => $model->city));
$district = CHtml::listData($district_data, "id", "name");
}
$district_update = $model->isNewRecord ? array() : $district;
echo CHtml::dropDownList('AddressResult[district]', $d_default, $district_update, array('empty' => '请选择地区'));
?>
<?php
echo $form->textFieldRow($model, 'zipcode', array('class' => 'span2'));
?>
</div>
<?php
echo $form->textFieldRow($model, 'address', array('class' => 'span5'));
?>
示例14: model
public static function model($className = __CLASS__)
{
return parent::model($className);
}
示例15: showDetailAddress
public function showDetailAddress($model)
{
$data['receiver_country'] = $model->receiver_country;
foreach (array('state', 'city', 'district') as $value) {
$data['receiver_' . $value] = Area::model()->findByPk($model->{'receiver_' . $value})->name;
}
$data['receiver_address'] = $model->receiver_address;
$detail_address = implode(' ', $data);
return $detail_address;
}