I was able to sort my related data on field that was another level deep in the relationship, but I'm not sure if it's the "Cake" way since it required me to write a very specific SQL fragment (subquery) . Let me try to explain with a simple example:
Let's say I have a dynamically generated questionnaire that contains many questions, and I want to sort those questions based on a display_order field. When an instance of a questionnaire gets generated, an instance of each question is also generated. The questions are all defined in a library of questions, if you will (table name is "questions"), where the display_order field is maintained. So, to control the display order of my question instances within a Questionnaire, the model definition for Questionnaire has this relationship defined with the 'order' parameter set with a specific sub-query: var $hasMany = array( 'QuestionInstance' =>array('className' => 'QuestionInstance', 'foreignKey' => 'question_instance_id', 'conditions' => '', 'fields' => '', 'order' => '(Select Question.display_order FROM questions AS Question WHERE QuestionInstance.question_id = Question.id) ASC', 'limit' => '', 'offset' => '', 'dependent' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => ''), ); Is there a better, or preferred way to accomplish the same sort without explicitly writing a sub-query? I thought that by putting "Question.display_order" for the 'order' parameter would work, but it did not. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---