yii中给CGridView设置默认的排序根据时间倒序的方法

阅读更多
public function searchWithRelated() {
        $criteria = new CDbCriteria;

        $criteria->together = true; //without this you wont be able to search the second table's data
        $criteria->with = array('mySecondTable');
        $criteria->compare('id', $this->id, true);
        $criteria->compare('mySecondTable.column', $this->mySecondTable_column, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
            'sort'=>array(
               'defaultOrder'=>'t.create_time DESC',
            ),
            'pagination' => array(
                'pageSize' => 100,
            ),
        ));
    }

你可能感兴趣的:(yii中给CGridView设置默认的排序根据时间倒序的方法)