本文整理汇总了PHP中Region::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Region::model方法的具体用法?PHP Region::model怎么用?PHP Region::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Region
的用法示例。
在下文中一共展示了Region::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNonCurrentRegions
public function getNonCurrentRegions()
{
if (null === $this->_nonCurrentRegions) {
$this->_nonCurrentRegions = Region::model()->findAll('id != :regionId', array(':regionId' => $this->currentRegion->id));
}
return $this->_nonCurrentRegions;
}
示例2: loadRegion
public function loadRegion($id)
{
$model = Region::model()->findByPk($id);
if (null === $model) {
throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.'));
}
return $model;
}
示例3: utcToLocal
public function utcToLocal($datetime)
{
$region = Region::model()->findByPk(Yii::app()->session['region']);
$timeZoneName = $region->time_zone;
$timezone = new DateTimeZone($timeZoneName);
$offset = $timezone->getOffset(new DateTime());
return strtotime($datetime) + $offset;
}
示例4: beginRequest
public function beginRequest()
{
Yii::import('application.widgets.LanguageSelector');
LanguageSelector::setLanguage();
if (null === Yii::app()->session['region'] || !Region::model()->exists('id = :id', array(':id' => Yii::app()->session['region']))) {
Yii::app()->session['region'] = Region::model()->getDefault()->id;
assert(null !== Yii::app()->session['region']);
}
}
示例5: parseUrl
public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
{
$region = Region::model()->findByAttributes(array('slug' => $pathInfo));
if (null === $region) {
return FALSE;
}
$_GET['id'] = $region->id;
return 'location/map';
}
示例6: getNameById
public static function getNameById($id)
{
if (empty(self::$nameById[$id])) {
$c = Region::model()->findByPk($id);
if ($c) {
self::$nameById[$id] = $c->name;
}
}
return self::$nameById[$id];
}
示例7: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
if (Yii::app()->getLanguage() == "ru") {
$lang = "ru";
} else {
$lang = "ua";
}
$model = Region::model()->findByPk(array('id' => $id, 'lang' => $lang));
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例8: getRegionInfoByIds
/**
* 根据id获取地区名详细数组.
* @param $ids
* @return bool|string
*/
public function getRegionInfoByIds($ids)
{
if (empty($ids) || !is_array($ids)) {
return false;
}
$list = Region::model()->findAllByAttributes(array('id' => $ids));
if (empty($list)) {
return false;
}
$data = array();
foreach ($list as $row) {
$data[$row->id] = $row->getAttributes();
}
return $data;
}
示例9: actionIndex
public function actionIndex()
{
$this->pageTitle = Yii::t('common', '品牌中心') . SEPARATOR . Setting::getValueByCode('inside_title', true);
$criteria = new CDbCriteria();
$criteria->compare('t.is_released', 1);
$criteria->order = 'sort_order ASC';
$brands = Brand::model()->localized()->findAll($criteria);
// 广告图
$criteria = new CDbCriteria();
$criteria->compare('t.banner_position_id', 2);
$banner = Banner::model()->localized()->find($criteria);
$codes = BrandI18n::model()->getFirstCode();
$this->layout = 'main';
$regions = Region::model()->getSelects();
$this->render('index', array('brands' => $brands, 'regions' => $regions, 'banner' => $banner, 'codes' => $codes));
}
示例10: parseUrl
public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
{
if (!preg_match('%^(\\w+)/resources(/(.+)s)?$%', $pathInfo, $matches)) {
return FALSE;
}
$regionSlug = $matches[1];
$region = Region::model()->findByAttributes(array('slug' => $regionSlug));
$type = isset($matches[3]) ? $matches[3] : null;
if (null === $region) {
return FALSE;
}
$_GET['region'] = $region->id;
if (null !== $type) {
$_GET['type'] = $type;
}
return 'resource/list';
}
示例11: getUserAddressList
/**
* 根据用户id获取用户的地址信息列表数组.
* @param $userId
* @return array|bool
*/
public function getUserAddressList($userId)
{
$map = array();
$map['user_id'] = $userId;
$list = Address::model()->findAllByAttributes($map);
if (empty($list)) {
return false;
}
$newList = array();
$is_default = false;
$first_key = 0;
foreach ($list as $val) {
$temp = $val->getAttributes();
if ($temp['is_default'] && $is_default == false) {
$is_default = true;
} else {
$temp['is_default'] = 0;
}
if (!$first_key) {
$first_key = $temp['id'];
}
$ids = array();
$ids[] = intval($val['province']);
$ids[] = intval($val['city']);
$ids[] = intval($val['district']);
$map = array();
$map['id'] = $ids;
$addList = Region::model()->findAllByAttributes($map);
if (empty($addList)) {
continue;
}
$regionList = array();
foreach ($addList as $row) {
$regionList[$row['id']] = $row->getAttributes();
}
$temp['province_name'] = isset($regionList[$val['province']]) ? $regionList[$val['province']]['region_name'] : '';
$temp['city_name'] = isset($regionList[$val['city']]) ? $regionList[$val['city']]['region_name'] : '';
$temp['district_name'] = isset($regionList[$val['district']]) ? $regionList[$val['district']]['region_name'] : '';
$newList[$val->id] = $temp;
}
if ($is_default == false && !$first_key) {
$newList[$first_key]['is_default'] = 1;
}
return $newList;
}
示例12: actionSearch
/**
* Action to search ads by key words
*/
public function actionSearch($id = null, $word = null, $city_id = null, $page = null)
{
$criteria = new CDbCriteria();
$criteria->condition = "status='published'";
$criteria->order = 'added DESC';
$form = new EavSearchForm();
if ($id) {
$category = Category::model()->findByPk($id);
$childrenIds = $category ? $category->getDescendantIds() : null;
if ($childrenIds) {
$criteria->addInCondition('category_id', $childrenIds);
} else {
$criteria->addCondition('category_id=:category_id');
$criteria->params[':category_id'] = intval($id);
}
$form->model->attachEavSet($category->set_id);
$form->eav = $form->model->getEavAttributes();
if (isset($_GET['search'])) {
$form->fill();
$this->buildEavCriteria($criteria);
}
}
if ($word) {
try {
$ids = $this->sphinxSearch($word);
$criteria->addInCondition('t.id', $ids);
} catch (Exception $e) {
$criteria->addCondition('title LIKE :word1 OR description LIKE :word2');
$criteria->params[':word1'] = "%{$word}%";
$criteria->params[':word2'] = "%{$word}%";
}
}
if ($city_id) {
$criteria->addCondition('city_id=:city_id');
$criteria->params[':city_id'] = intval($city_id);
}
$regions = Region::model()->getRegionList();
$dp = new EavActiveDataProvider('Ad', array('criteria' => $criteria, 'countCriteria' => array('condition' => $criteria->condition, 'params' => $criteria->params), 'pagination' => array('pageSize' => 10)));
$this->render('search', array('dataProvider' => $dp, 'form' => $form, 'regions' => $regions));
}
示例13: parseUrl
public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
{
if (!preg_match('%^([\\w-]+)/([\\w-]+)?$%', $pathInfo, $matches)) {
return FALSE;
}
$regionSlug = $matches[1];
$actionOrLocationSlug = $matches[2];
$region = Region::model()->findByAttributes(array('slug' => $regionSlug));
if (null === $region) {
return FALSE;
}
if ('spaces' === $actionOrLocationSlug) {
$_GET['id'] = $region->id;
return 'location/list';
}
$location = Location::model()->findByAttributes(array('slug' => $actionOrLocationSlug, 'region_id' => $region->id));
if (null === $location) {
return FALSE;
}
$_GET['id'] = $location->id;
return 'location/view';
}
示例14: actionFindRegion
public function actionFindRegion()
{
$q = $_GET['term'];
if (isset($q)) {
$lang = Yii::app()->getLanguage();
if ($lang == "uk_ua") {
$lang = "ua";
}
$criteria = new CDbCriteria();
$criteria->params = array(':q' => '%' . trim($q) . '%');
$criteria->condition = 'name LIKE (:q) and lang="' . $lang . '"';
$regions = Region::model()->findAll($criteria);
if (!empty($regions)) {
$out = array();
foreach ($regions as $p) {
$out[] = array('label' => $p->name, 'value' => $p->name, 'id' => $p->id);
}
echo CJSON::encode($out);
Yii::app()->end();
}
}
}
示例15: array
<div class="localidad col-md-12">
<input type="hidden" class="val" value="<?php
echo $i;
?>
">
<div class="col-md-3">
<?php
echo $form->dropDownListGroup($localidad, 'region_id', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => CHtml::listData(Region::model()->findAll(), 'id', 'nombre'), 'htmlOptions' => array('class' => 'region', 'name' => 'Localidad[' . $i . '][region_id]', 'prompt' => 'Seleccione Region'))));
?>
</div>
<div class="col-md-3">
<?php
echo $form->dropDownListGroup($localidad, 'comuna_id', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('data' => CHtml::listData(Comuna::model()->findAllByAttributes(array('region_id' => $localidad->region_id), array("select" => "nombre,id")), 'id', 'nombre'), 'htmlOptions' => array('class' => 'comuna', 'name' => 'Localidad[' . $i . '][comuna_id]', 'prompt' => 'Seleccione Comuna'))));
?>
</div>
<div class="col-md-3">
<?php
echo $form->textFieldGroup($localidad, 'direccion', array('wrapperHtmlOptions' => array('class' => 'col-sm-5'), 'widgetOptions' => array('htmlOptions' => array('name' => 'Localidad[' . $i . '][direccion]'))));
?>
</div>
<?php