Has anyone looked into this further? I'm finding this very frustrating. It
just makes sense to have associations nested, but I do not understand for
the life of me why this doesn't happen for the root model item.
Frank Weindel
On Tuesday, May 4, 2010 4:26:12 AM UTC-4, Roland B wrote:
>
> 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 [email protected]<javascript:>
> To unsubscribe from this group, send email to
> [email protected] <javascript:> For more options, visit this
> group at http://groups.google.com/group/cake-php?hl=en
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.