如何按日期顺序显示数据提供者数据?

时间:2014-04-18 09:20:31

标签: php yii

我使用此代码。但我没有得到答案。

$criteria=new CDbCriteria;        
                    $dataProvider=new CActiveDataProvider('Holiday', array(
                    'criteria'=>array('condition'=>'Date orderby desc'),
                    'pagination'=>array(
                    'pageSize'=>Yii::app()->controller->module->user_page_size,
                ),
            )); 

1 个答案:

答案 0 :(得分:1)

应该是:

$criteria=new CDbCriteria;        
                $dataProvider=new CActiveDataProvider('Holiday', array(
                'criteria'=>array('order'=>'Date desc'),
                'pagination'=>array(
                'pageSize'=>Yii::app()->controller->module->user_page_size,
            ),
        )); 

$criteria = new CDbCriteria();
$criteria->order = 'date DESC';
$dataProvider=new CActiveDataProvider('Holiday', array(
                'criteria'=>criteria,
                'pagination'=>array(
                'pageSize'=>Yii::app()->controller->module->user_page_size,
            ),
        ));