lalitesh
(Luckyglucks)
1
I am new to Yii and unfamiliar with the widgets and CActiveDataProvider etc.
I have a table name t_orders with attribute like created.
My model name is Order.php
Controller name is OrdersController.php
I want to know that how can I apply sorting on the created attribute in ASC or DESC.
twisted1919
(Serban Cristian)
2
$criteria = new CDbCriteria();
$criteria->order = 'created DESC';
$models = Order::model()->findAll($criteria);
$criteria can also be passed to data providers as:
public function search()
{
$criteria=new CDbCriteria;
return new CActiveDataProvider(get_class($this), array(
'criteria' => $criteria,
'pagination' => array(
'pageSize' => 10,
'pageVar' => 'page',
),
'sort' => array(
'defaultOrder' => array(
'created' => CSort::SORT_DESC,
),
),
));
}
There’s plenty documentation clearing this out…
lalitesh
(Luckyglucks)
3
What code should i write on front-end (view file)…?