Yii framework DataProvider default order
2011.09.08
The widgets of the Yii framework are using a so called 'dataprovider'. They support the order of the data by any attribute but in some cases we need a default order. To achive this we need to set the 'defaultOrder' property of the 'sort' property(which is a CSort class) of the dataProvider:
$dataProvider=new CActiveDataProvider('Post', array(
'criteria'=>array(
'condition'=>'status=1',
'with'=>array('author'),
),
'sort' => array(
'defaultOrder' => 'create_time DESC'
),
'pagination'=>array(
'pageSize'=>20,
),
));

