Reputation: 203
How can I sort by PK in this case?
$model=new SupportTicket('search');
I can do that using search method inside the model, but I have to do that with object. Sure I can rewrite standard method using DbCriteria, but probably easy way exists?
Upvotes: 1
Views: 1045
Reputation: 36
You can use sort
in your in search()
model:
return new CActiveDataProvider($this, array(
'criteria' => $criteria,
'sort' => array('defaultOrder' => 'id DESC'),
));
Upvotes: 0
Reputation: 380
I always use the find methods provided by CActiveRecord:
$model = SupportTicket::model()->findAll(array('order'=>'PK'));
Upvotes: 1
Reputation: 1305
On 'search()' method, you can put:
$criteria=new CDbCriteria;
$criteria->order = 'id ASC';
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
Upvotes: 1