【问题标题】:$paginator->numbers(); not working in cakephp$分页器->数字();不在 cakephp 中工作
【发布时间】:2010-12-02 21:14:10
【问题描述】:

我正在尝试将 Cakephp 中的分页概念用于我的应用程序..

var $paginate = 数组( '限制' => 5, '订单' => 数组( 'Report.report_id' => 'desc' ) );

在 cakephp 动作中

        $conditions=array('Report.user_id'=>$userId);
        $this->paginate['Report']['conditions']=$conditions;
        $this->paginate['Report']['group']='Report.report_id';
        $this->paginate['Report']['limit']=5;
        $allreports=$this->paginate('Report');

现在这给了我查询的实际 5 个条目,按条件分组,但我现在没有在视图中获得页码..

在视图中

我用过喜欢

         <?php  echo $paginator->numbers(); ?> 

但它没有显示任何内容??为什么这样..指导我...

【问题讨论】:

    标签: cakephp


    【解决方案1】:

    虽然Model::find() 支持group 参数,但对分页的支持尚未实现。如果将group 传递给$paginate,虽然会返回正确的结果,但会返回不一致的记录COUNT(用于确定页数)。有一个ticket to add support for this,但直到 CakePHP 2.x 才会实现。同时,您必须按照手册中Custom Query Pagination 下的示例中所述覆盖模型中的paginateCount()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-06
      • 2016-06-12
      • 2018-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-16
      相关资源
      最近更新 更多