I'm talking about users_controller.php, and I want to return every books that a users own (in few words I need rows from albums_users table). It seems that i fall in first section written by cricket "If you're fetching a single User and you'd like to see their Books in the data: ", in this way (with find) I get all data in one time, but i need it paginated, what I've to do after find?
On 3 Ott, 22:48, cricket <[email protected]> wrote: > On Sun, Oct 3, 2010 at 4:31 PM, Mariano C. <[email protected]> wrote: > > How can I rewrite my function to do things like u suggested??? > > > On 2 Ott, 21:53, "Mariano C." <[email protected]> wrote: > >> my function that paginate is something like > > >> function ... paging() > >> { > >> $this->paginate = array(.....); > >> $books = $this->paginate('Book'); > >> // this is where i can get the information printed in first post > >> $this->set(compact('books')); > > >> } > > It's unclear to me which controller we're talking about. You mentioned > paginating books but also that what you're interested in is a > particular User's Books. Unless you mean that you want to paginate a > particular User's Books, maybe? > > If you're fetching a single User and you'd like to see their Books in the > data: > > $data = $this->User->find( > 'first', > array( > 'conditions' => array( > 'User.id' => $id > ), > 'fields' => array('...'), > 'contain' => array( > 'Book' > ) > ) > ); > > If you're paginating several Users and you'd like to include each of > their Book collections: > > public $paginate = array( > 'fields' => array('*'), > 'limit' => 10, > 'order' => array('User.surname' => 'ASC'), > 'contain' => array( > 'Book' => array( > 'fields' => array( > 'Book.id', > 'Book.title' > ), > 'order' => array('Book.title' => 'ASC') > ) > ) > ); > > public function index() > { > $this->set( > 'data' > $this->paginate() > ); > > } > > If you're paginating Books and want to see theUsers who have each in > the collections: > > public $paginate = array( > 'fields' => array('*'), > 'limit' => 10, > 'order' => array('Book.title' => 'ASC'), > 'contain' => array( > 'User' => array( > 'fields' => array( > 'User.id', > 'User.surname' > ), > 'order' => array('User.surname' => 'ASC') > ) > ) > ); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
