You're right, in Cake lingo this is called HABTM, in normal database
ERD's they both have a Has Many relationship with eachother....
ofcourse I have modeled this with HABTM, but thanks for your
correction!
Your solution to the order problem is 'spot on', actually what I was
looking for! I didn't knew that this was possible from within the
model.
GriGri, thanks for elaborating on the FindByFieldname() function, I
was using findBySlug() for ages, and was already wondering by this
wasn't in the API... LOL.... just some more Cake magic indeed!
On Oct 18, 11:30 am, "Amit Badkas" <[EMAIL PROTECTED]> wrote:
> On 10/18/07, BoSc <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > I've got 3 tables with a 1:n relationship:
>
> > - author (has many books)
> > ^
> > |
> > |
> > V
> > - books (belongs to categories) (has many authors)
>
> - I think you made a mistake here, actual relationships may be author HABTM
> books and books HABTM authors
>
> |
>
>
>
> > |
> > V
>
> > - categories (has many books)
>
> > What I would like to do on one page, is show a categorized view of all
> > books by a specific author. The problem lies in the fact that each
> > category and each book also has some kind of sorting involved, which
> > states at what place in a category a book should be shown...
>
> > >From which Point of View should I query this, and am I able to
> > implement this in 1 query?
>
> > What I would like to end up with is the following array
>
> > array
> > category 2
> > book 1
> > name
> > blabla
> > book 3
> > name
> > blabla
> > book 2
> > name
> > blabla
> > category 1
> > book 4
> > name
> > blabla
> > book 6
> > name
> > blabla
> > book 5
> > name
> > blabla
>
> > The problem is, when I use findAll on Category, I'm not able to choose
> > how Cake should order the Books. Any workarounds?
>
> - Use Category->findAll(null, null, 'Category.name ASC'); and in category
> model, define hasMany relation with book like, $hasMany = array('Book' =>
> array('order' => 'Book.name ASC'));
>
> --
> Regards,
> Amit
>
> http://amitrb.wordpress.com/http://cheesecake-photoblog.org/http://www.sanisoft.com/blog/author/amitbadkas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---