> Hi.
>
> I can see that ORDER'ing related models have been discussed before,
> but I haven't found a solution.
>
> I basically have 3 tables/models: Item, User, Person
>
> Item has $hasAndBelongsToMany = array('User');
>
> and User has $belongsTo = array('Person');
>
> Person has a field "name", and when I retrieve an item, I would like
> the related users to be ordered by Person.name.
>
> I tried to add an order clause to the HABTM-definition:
> Item: $hasAndBelongsToMany = array('User'=>array
> ('order'=>'Person.name'));
> - but this gives an SQL-error (Person.name not found).
>
> I can see that Cake is not baking any JOINs for me - instead there is
> a SELECT statement for each person in the SQL-log...
>
> I have tried to experiment with "recursive", but that doesn't seem to
> change anything. What is the Cake-way to sort like this?
Did you ever find a solution to this? I've been fighting the same
battle for hours now and haven't been able to solve it. Would love to
hear what you ended up doing, if you found something that works.
In my case, I have NavMenu and NavMenuItem models and each habtm the
other. I'd like to retrieve all NavMenu records and their associated
items, but have the nested NavMenuItem array ordered as needed:
$this->NavMenu->find ( 'all', array ( 'order' =>
'NavMenuItem.display_order' ) )
Of course, I get the same message (save for the model/field names, of
course) that you're reporting.
Thanks.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment