Reputation: 3267
This is my code ,here how can i give orderby .
$this->set('added', $this->paginate('TravancoMarketing', array('status = 0', 'assigned_by = '.$user_level)));
Here i want to give order by TravancoMarketing.id DESC
How can i give this?
Upvotes: 0
Views: 78
Reputation: 1506
in your controller you should declare something like this:
public $paginate = array(
'order' => array(
'TravancoMarketing.id' => 'DESC'
)
);
Upvotes: 0
Reputation: 4313
You can either add it as the default order by to the TravancoMarketing model:
class TravancoMarketing {
public $order = array('TravancoMarketing.id'=>'DESC');
}
or to the paginate query itself:
$this->paginate = array(
'conditions'=>array(
'TravancoMarketing.status'=>0,
'TravancoMarketing.assigned_by'=>$user_level
),
'order'=>array(
'TravancoMarketing.id'=>'DESC'
)
);
$this->set('added', $this->paginate('TravancoMarketing'));
Upvotes: 1