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(
[color=red] 'defaultOrder'=>'t.create_time DESC',[/color]
),
'pagination' => array(
'pageSize' => 100,
),
));
}

你可能感兴趣的:(YII)