I have five tables: users, books, books_users, authors and types. users, authors and types just have PK field called id. books have PK called id and FK called author_id (ref. Authors) books_users have PK called id and 3 FKs user_id, book_id, type_id (respectively Ref. users, books, types).
I have create 5 model (Book, Author, User, BooksUser and Type) and arranged the associations as: Book belongsTo Author Book hasMany BooksUser Author hasMany Book User hasMany BooksUser BooksUser belongsTo Book, User, Type Type hasMany BooksUser Now I want to know every user's book, so I will query (and paginate) books_users table, in user's controller: function myfunction( my params) { $this->paginate = array ( 'page' => $page, 'limit' => $limit, 'order' => $order, 'joins' => array ( array ( 'table' => 'books_users', 'alias' => 'BooksUser', 'type' => 'INNER', 'conditions' => array ( 'Book.id = BooksUser.book_id', ) ), array ( 'table' => 'types', 'alias' => 'Type', 'type' => 'INNER', 'conditions' => array ( 'BooksUser.type_id = Type.id' ) ), ), 'fields' => array ( 'Book.id', 'Book.title', 'Author.id', 'Author.name', 'BooksUser.id', 'Type.id', 'Type.name' ), 'conditions' => array ( array('BooksUser.user_id' => $username_id) ) ); $books = $this->paginate('Book'); $this->set(compact('books')); } // end function This work properly and returns me: Array ( [0] => Array ( [Book] => Array ( ... ) [Author] => Array ( ... ) [BooksUser] => Array ( [id] => 6060-4ff8-84da-40f68afdf92b [0] => Array ( [id] => 6060-4ff8-84da-40f68afdf92b [book_id] => b647-4b81-bcaf-f1596d11c9bb [user_id] => 8428-4729-b324-05b08afdf92b [type_id] => 5 [created] => 2010-10-17 19:17:51 ) [1] => Array ( [id] => 324c-488b-bf7f-4a658afdf92b [book_id] => b647-4b81-bcaf-f1596d11c9bb [user_id] => e9b8-43ea-9a17-fe908afdf92b [type_id] => 1 [created] => 2010-10-17 21:05:09 ) ) [Type] => Array ( ... ) ) ) It's ok, but I want just first record (array's element [0]) inside BooksUser, cause i'm interested just about 8428-4729-b324-05b08afdf92b user. I need a sort of find('first') for pagination? How can i do? 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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en