• 3rd July 2009 - By dan

    For a CakePHP n00b the pagination thing might seem a bit complicated. Well to be frank it is in someways. For instance you can only currently paginate stuff easily when there is a model involved!

    For instance here is a pagination with a deep association:

    $this->UserProfile->User->Friend->recursive = -1;
    		$this->set('userFriends', $this->paginate($this->UserProfile->User->Friend, 
    			array('Friend.user_id' => $userid, 'Friend.accepted' => 1)));
     
    		$this->set('userFriendsWaiting', $this->paginate($this->UserProfile->User->Friend,
    				array('Friend.user_id' => $userid, 'Friend.accepted' => 0, 'Friend.rejected' => 0)));
     
    		$this->set('userFriendsRejected', $this->paginate($this->UserProfile->User->Friend,
    				array('Friend.user_id' => $userid, 'Friend.accepted' => 0, 'Friend.rejected' => 1)));

    in this it is to ensure that you have the paginate var set in your Friend Model – and that each conditions field (the stuff in the array() is prefixed with the table of this model

    Hope this clears it up

    Share with your friends and help out this site:
    • Digg
    • del.icio.us
    • Facebook
    • Google Bookmarks
    • E-mail this story to a friend!
    • LinkedIn
    • Live
    • Reddit
    • StumbleUpon
    • Twitter
    • Yahoo! Bookmarks

Ad