简体   繁体   English

为什么CakePHP 1.3分页忽略了我的订单?

[英]Why is CakePHP 1.3 Pagination ignoring my order?

I have a reports model, and I for the life of me cannot get it to change the order because of the use of the $this->paginate() in displaying the data. 我有一个报告模型,由于使用了$ this-> paginate()来显示数据,我一生中都无法改变它的顺序。 What am I doing wrong? 我究竟做错了什么? It's as if the $paginate variable I set up has no impact whatsoever on the next line where $this->paginate() is called. 好像我设置的$ paginate变量对调用$ this-> paginate()的下一行没有任何影响。

$this->Report->recursive = 0;
$paginate = array('order' => array('Report.id' => 'DESC'));
$this->set('reports', $this->paginate());

UPDATE: 更新:

I have tried a few more things, with no success at all. 我尝试了几件事,但都没有成功。

  1. I tried declaring the $paginate variable outside of the Report controller's index. 我尝试在Report控制器的索引之外声明$ paginate变量。 This caused the page to not load 这导致页面无法加载
  2. $paginate = array('order' => array('Report.id' => 'asc'),'limit' => 5); $ paginate = array('order'=> array('Report.id'=>'asc'),'limit'=> 5);
  3. $paginate = array('Report' => array('order' => array('Report.id' => 'asc'),'limit' => 5)); $ paginate = array('Report'=> array('order'=> array('Report.id'=>'asc'),'limit'=> 5));
  4. $paginate = array('order' => array('Report.id ASC'),'limit' => 5); $ paginate = array('order'=> array('Report.id ASC'),'limit'=> 5);
  5. $paginate = array('order' => array('id' => 'asc'),'limit' => 5); $ paginate = array('order'=> array('id'=>'asc'),'limit'=> 5);

Neither the order, or the limit have any effect on the output of $this->paginate(); 顺序或限制都不会影响$ this-> paginate()的输出;

Try this.. 尝试这个..

$this->paginate = array('Report' => array('order' => 'Report.id' => 'DESC'));

Replace your second line 替换第二行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM