这是我的代码,在这里我该如何给出orderby。
$this->set('added', $this->paginate('TravancoMarketing', array('status = 0', 'assigned_by = '.$user_level)));
我想在此提供order by TravancoMarketing.id DESC
我怎么能给这个?
答案 0 :(得分:1)
您可以将其作为默认订单添加到TravancoMarketing模型中:
class TravancoMarketing {
public $order = array('TravancoMarketing.id'=>'DESC');
}
或分页查询本身:
$this->paginate = array(
'conditions'=>array(
'TravancoMarketing.status'=>0,
'TravancoMarketing.assigned_by'=>$user_level
),
'order'=>array(
'TravancoMarketing.id'=>'DESC'
)
);
$this->set('added', $this->paginate('TravancoMarketing'));
答案 1 :(得分:0)
public $paginate = array(
'order' => array(
'TravancoMarketing.id' => 'DESC'
)
);