Leonardo Barnabe Wed Jul 27 12:35:17 -0400 2011

Subject: Multiple joins

Hi, let's say I have a book that has an author and a preface, and its preface has an author.
How could I make the necessary joins so I can get book->author and book->preface->author in the same find?

Thanks in advance...

Beau Frusetta Wed Aug 03 18:17:33 -0400 2011

Book belongs_to Preface
Preface belongs_to Author

Author has_many Books
Preface has_many Books

Something like that setup should work.

Leonardo Barnabe Sat Aug 06 18:16:16 -0400 2011

Thanks for your reply, Beau,

I found what I was looking for.
That's what I wanted:

Book::find('all', array(
'joins' => array('author', 'preface'),
'include' => array('author', 'preface' => array('usuarios'))