2014-03-26 68 views
0

中的方法我想得到任何幫助。我想在Controller中編寫分頁,可以從Model中的方法中檢索數據。注意我使用cakephp。Cakephp分頁鏈接到模型

在控制器這是功能uploadDocumentForm

function uploadDocumentForm() 
     { 
       if(!$this->User->checkPrivilege(array(6))) { 
         throw new ForbiddenException(); 
       } 
       $userID = $this->Session->read('userID'); 
       $this->set('documentList',$this->SystemParameter->getDocumentList("DOCUMENT_TYPE")); 
       $this->set('studentUploadDocumentList',$this->Document->getDocumentByUserID($userID)); 

這是在文檔模型getDocumentByUserID功能

function getDocumentByUserID($anUserID) 
     { 
       return $this->find('all',array('conditions'=>array('Project.student_user_id'=>$anUserID),'order'=>array('Document.document_id'=>'desc'))); 
     } 

所以,我怎麼能代碼控制分頁鏈接到getDocumentByUserID? 非常感謝您

Ponom

+3

你是什麼實際問題?我真的不明白你在這裏做什麼。 – Oldskool

+0

這是我的問題?我錯過打字。我怎樣才能在控制器鏈接到getDocumentByUserID代碼分頁? – user41065

回答

1

這是官方文檔中涵蓋in the chapter about the pagination component,讀它。

如果您無法使用標準查找選項創建 查詢,則需要顯示數據,但有幾個選項。您可以使用自定義查找類型 。您還可以在模型上實現paginate()和 paginateCount()方法,或將它們包含在與模型相連的行爲 中。行爲實現分頁和/或 paginateCount應該實現與$模型的正常額外的第一個參數如下 定義的方法簽名: