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


PHP Objects::getCSort方法代码示例

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


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

示例1: actionView

 public function actionView()
 {
     $model = $this->_loadModel(Yii::app()->request->getQuery('url'));
     $cr = new CDbCriteria();
     if ($model) {
         $this->pageTitle = $model->title . ' - Быстрые отзывы покупателей';
         $modelFirst = $model;
         $name = $model->title;
         $cr->addCondition('t.categorie=' . $model->id);
     }
     // $query = Objects::model()->cache(3600);
     $cr->select = 't.*';
     $query = new Objects(null);
     $query->attachBehaviors($query->behaviors());
     $query->applyAttributes($this->activeAttributes)->active();
     //  ->with('images');
     $query->getDbCriteria()->mergeWith($cr);
     $provider = new CActiveDataProvider($query, array('id' => false, 'pagination' => array('pageSize' => 25)));
     $provider->sort = Objects::getCSort('t.created_date DESC, t.title');
     $itemView = '_objects_view';
     $count_items = $provider->totalItemCount;
     $criteria = new CDbCriteria();
     $criteria->scopes = 'active';
     $dataProvider = new CActiveDataProvider('Objects', array('criteria' => $criteria, 'sort' => array('defaultOrder' => 't.created_date DESC'), 'pagination' => array('pageSize' => 30)));
     $sql = 'select count(*) cnt, categorie
             from objects
             WHERE objects.status=' . Objects::STATUS_ACTIVE . '
             group by categorie';
     $connection = Yii::app()->db;
     $command = $connection->createCommand($sql);
     $rows = $command->queryAll();
     $search = false;
     $this->render('view', array('provider' => $provider, 'model' => $model, 'itemView' => $itemView, 'per_page' => 25, 'count_items' => $count_items, 'rows' => $rows, 'search' => $search));
 }
开发者ID:Aplay,项目名称:Fastreview_site,代码行数:34,代码来源:FastreviewController.php

示例2: search

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search($params = array(), $additionalCriteria = null, $pagination = true)
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;
		

		if($additionalCriteria !== null)
			$criteria->mergeWith($additionalCriteria);

		if($this->id)
			$this->id = (int)$this->id;
		$criteria->compare('t.id',$this->id);
		if($this->title){
			$criteria->compare('LOWER(t.title)',MHelper::String()->toLower($this->title),true);
		}
		$criteria->compare('LOWER(t.description)',MHelper::String()->toLower($this->description),true);
		$criteria->compare('LOWER(t.address)',MHelper::String()->toLower($this->address),true);
		$criteria->compare('LOWER(t.street)',MHelper::String()->toLower($this->street),true);
		$criteria->compare('LOWER(t.dom)',MHelper::String()->toLower($this->dom),true);
		$criteria->compare('t.city_id',$this->city_id);
		$criteria->compare('t.link',$this->link,true);
		$criteria->compare('t.url',$this->url,true);
		$criteria->compare('t.created_date',$this->created_date,true); 
		$criteria->compare('t.status',$this->status);
		$criteria->compare('t.categorie', $this->categorie);

		$criteria->compare('t.author', $this->author);

        if($pagination){
        	return new CActiveDataProvider($this, array(
				'criteria'   => $criteria,
				'sort'       => Objects::getCSort(),
				'pagination' => array(
					'pageSize'=>50,
				)
			));
        } else {
        	return new CActiveDataProvider($this, array(
				'criteria'   => $criteria,
				'sort'       => Objects::getCSort('t.id'),
				'pagination' => false
			));
        }
		
	}
开发者ID:Aplay,项目名称:Fastreview_site,代码行数:58,代码来源:Objects.php


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