I tried to do something very similar not so long ago, and too had trouble getting it to do as I wanted.
In the end not having time to pursue it further I did just sort after the query was made, as far as I could tell due to the way habtm's are querried it wasn't a simple case of altering the association settings etc. I'd be interested to see if anyone has some clear thoughts on this too. -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of David Spreekmeester Sent: Friday, 26 October 2007 9:02 a.m. To: Cake PHP Subject: ordering a model through related model order Hey there bakers. I couldn't find an appropriate answer to this anywhere. Suppose I have three models: Bakery <- hasAndBelongsToMany -> Baker <- hasAndBelongsToMany -> Cookie Suppose there is a cookie baking contest going on. Every cookie is rated for quality (int Cookie.quality). I would like to do a find() for a certain bakery, and then *sort the employed bakers there by the rate of their baked cookies*. I tried stuff like setting the 'order' property to 'Cookie.quality' in the Cookie model file, but of course that just orders the cookies, and doesn't sort the bakers. The same goes for setting 'Cookie.quality' as the sorting parameter in the find() call. Of course I could just sort the bakers afterwards with my own custom sort function, but is there a way to do this automagically? __________ NOD32 2617 (20071025) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
