Hi,

is there a way to change the structure of data returned by a model's
find call? Or should I use a different call? IMHO, the default seems
to be inconsistent in the way it handles associations:

Given this model:
//---------------------------------------
class Querycategory extends AppModel
{
   var $recursive = 10;
   var $hasMany = array(
          'Querycategory' => array('order' => 'name ASC'),
          'Querygroup'    => array('order' => 'name ASC'));
}
//---------------------------------------

A call to $this->Querycategory->find('all') yields something like
this:

Array
(
    [0] => Array
        (
            [Querycategory] => Array
                (
                    [id] => 70
                    [querycategory_id] => 34
                    [0] => Array
                        (
                            [id] => 71
                            [querycategory_id] => 70
                            [Querygroup] => Array
                                (
                                    [0] => Array
                                        (
                                            [id] => 43
                                            [querycategory_id] => 71
                                        )
                                )
                        )
                )
            [Querygroup] => Array
                (
                )
        )
)

A Querygroup belonging to the Root-Querycategory is at the same level
as the root node and it is called Querygroup.
A Querygroup belonging to a child category is inside that child node
and it is called Querygroup.
A Querycategory belonging to any other category is inside its parent
and unnamed, unless there is also a Querygroup at the same level: then
it is called 'Querycategory'

I would prefer:
Querygroup is always contained in it's "parent", always being called
'Querygroup'.
Querycategory is always contained in its "parent", always being called
'Querycategory'.

Is there a "standard way" to achieve this?

Using cake-1.2.


Thank you very much in advance,

Roland

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to