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
-~----------~----~----~----~------~----~------~--~---

Reply via email to