Yeah, I tried that, but I keep getting this error message, "SQL Error: 1054: Unknown column 'AdvancementCategory.id' in 'order clause'"
which makes sense to me. I am trying to sort by a field that requires or taps into the special abilities of the containable behaviour, which makes it difficult to use the standard sort option. Here is the sql query CakePHP is trying to run: $sql = "SELECT `Client`.`id`, `Client`.`firstname`, `Client`.`lastname`, `Client`.`family_id`, `Family`.`id`, `Family`.`advancement_id` FROM `clients` AS `Client` LEFT JOIN `families` AS `Family` ON (`Client`.`family_id` = `Family`.`id`) WHERE 1 = 1 ORDER BY `AdvancementCategory`.`id` ASC " Have we simply reached the limits of cakePHP? Can it deal with fields 3-4 models apart? It would have been very elegant to use CakePHP syntax to generate the array... :-( I guess I will have to write a custom query() instead. Unless one of you comes up with a genial idea! On Aug 3, 8:43 pm, JamesF <usaexportexpe...@gmail.com> wrote: > On Aug 3, 4:42 pm, pomares <k...@gordonpomarescentre.com> wrote:> I would > like a select menu filled with clients sorted by advancement > > category. Here are the models > > Client belongsTo Family > > add an order field to your find array, not in any of the contain sub- > arrays. > > ie > > 'order'=>'AdvancementCategory.id ASC' > > you also add order fields within your 'contain' sub arrays to sort > that subset within your larger dataset > > > Family belongsTo Advancement (i.e. status) > > Advancement belongsTo AdvancementCategory. > > > My code: > > > function clientList() { > > return $this->Client->find('all', array( > > 'fields' => array( > > > > 'id', > > > > 'firstname', > > > > 'lastname', > > > > 'family_id'), > > 'contain' => array( > > > > 'Family' => array( > > > > 'fields' =>array( > > > > 'id', > > > > 'advancement_id'), > > > > 'Advancement' => array( > > > > 'fields' =>array( > > > > 'id', > > > > 'advancement_category_id'), > > > > 'AdvancementCategory' => array( > > > > 'fields' => array( > > > > 'id', > > > > 'name'))))) > > )); > > } > > > Again, I would like the resulting array to be sorted by > > AdvancementCategory.id. > > > How do I do that? > > --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---