【问题标题】:cakephp paginator last record delete errorcakephp分页器最后一条记录删除错误
【发布时间】:2017-04-21 15:53:27
【问题描述】:

这里的示例,请检查是否发生

<?php                       
        echo $this->Paginator->prev
          ($this->Html->image('prev.png'), array('escape' => false), 
        array(), null, array('class' => 'prev'));
        echo $this->Paginator->counter
          ('Page {:page} of {:pages}, Total Records {:count}');                     
        echo $this->Paginator->next($this->Html->image
          ('next.png'), array('escape' => false), 
            array(), null, array('class' => 'next'));
     ?>

【问题讨论】:

    标签: cakephp pagination


    【解决方案1】:

    看看这个,希望它有效

    public function index() {
        try {
            $paginatedData = $this->Paginator->paginate();
        } catch (NotFoundException $e) {
            //get current page
            $page = $this->request->params['named']['page'];
            if( $page > 1 ){
                //redirect to previous page
                $this->redirect( array( "page" => $page-1 ) );
            }else{
                $paginatedData = array(); //no data to paginate so use empty array()
                                          //you will have to check for this in the view and no longer display the pagination links, since they will NOT be defined
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-28
      • 1970-01-01
      • 2018-10-03
      • 2015-10-18
      相关资源
      最近更新 更多