这是我的代码,我怎么可以给 orderby 。
$this->set('added', $this->paginate('TravancoMarketing', array('status = 0', 'assigned_by = '.$user_level)));
在这里我想给order by TravancoMarketing.id DESC
我怎么给这个?
这是我的代码,我怎么可以给 orderby 。
$this->set('added', $this->paginate('TravancoMarketing', array('status = 0', 'assigned_by = '.$user_level)));
在这里我想给order by TravancoMarketing.id DESC
我怎么给这个?
您可以将其作为默认订单添加到 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'));
在您的控制器中,您应该声明如下内容:
public $paginate = array(
'order' => array(
'TravancoMarketing.id' => 'DESC'
)
);