"order by" 无法在 CakePHP 2.6 分页中使用模型

"order by" not working with model in CakePHP 2.6 Pagination

我正在尝试调整此代码以对结果进行排序:

$result = $this->Paginate('ReceivedCargo', 
    array('PNR_BROKERS' => $id )
);`

我试过了:

$result = $this->Paginate('ReceivedCargo', 
    array('PNR_BROKERS' => $id),               
    array('ReceivedCargo.PNR' => 'desc')
);

我做错了什么?

尝试以下操作:

$this->Paginator->settings['ReceivedCargo']['conditions']['PNR_BROKERS']=$id
$this->Paginator->settings['ReceivedCargo']['order']=array(
    'ReceivedCargo.PNR' => 'DESC'
);
$result = $this->Paginator->paginate('ReceivedCargo');

顺便说一下,$this->Paginate() 已被弃用(为向后兼容而提供)。您应该直接访问 PaginatorComponent

有关更多信息,请参阅: