Look into findAllByThreaded() it does what you need without the extra overhead of an association. It requires a parent_id field (rather than parentid) and no other association or anything.
Geoff -- http://lemoncake.wordpress.com On Aug 6, 12:37 pm, housebolt <[EMAIL PROTECTED]> wrote: > I believe you can do it this way: > > for level 1: > $this->Category->findAllByParentId(0, null, 'Category.id ASC'); // > Third argument for findallby > > in your model, in the 'Childnode' array, add 'order'=>'Childnode.name > ASC' (or DESC depending on what you want) to the array. > > var $hasMany = array( > 'Childnode' => > array( > 'className' => 'Category', > 'foreignKey' => 'parentid', > 'order' => 'Childnode.name ASC' > ), > > I recommend the CakePHP cheat sheet from the CakePHP front page. > > On Aug 4, 7:18 am, "Feris Thia" <[EMAIL PROTECTED]> wrote: > > > Hi All, > > > I have a cake model which has a self join as follows.. > > > ================================== > > class Category extends AppModel { > > var $name = 'Category'; > > > var $hasMany = array( > > 'Childnode' => > > array( > > 'className' => 'Category', > > 'foreignKey' => 'parentid' > > ), > > ); > > ================================== > > > Then I query the model which return parent-child data using code below > > ========================================== > > $this->Category->recursive = 1; > > $category_data = $this->Category->findAllByParentid('0'); > > ========================================== > > > My question is, how can I set different order for every level, i.e. > > `id` order for level 1 and `name` for level 1 (joined data) ? > > > Thanks ! > > > Feris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
