2017-04-21 57 views
1

樣品在這裏,請檢查發生或不CakePHP的分頁程序最後一個記錄刪除錯誤

<?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')); 
    ?> 

回答

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 
     } 
    } 
} 
相關問題