I do think that if you don't like something in CakePHP, please write
your own solution to it, then offer it to the CakePHP developers.

I don't see anything wrong with the structure. What you suggest is to
add additional levels to the structure, just so that all records will
look equal inside the structure, starting from Parent through Node to
Child.

What I see that they have done, is eliminated unnecessary levels,
which for me is fine.

The first level holds the record of the model (Parent) you are
querying together with the one level related model (Node). I don't see
that as a problem. Second level holds the records of the model (Node)
together with the one level related model (Child) records. Fine with
me.

Take your own example and just add one more hasMany relationship to
the Parent model - Parent hasMany Ghost. If I would go for your
structure, then it would bring me:
[0]
   [Parent]
      [0]
         [Node]
            [0]
               [Child]
            [1]
               [Child]
      [1]
         [Node]
            [0]
               [Child]
            [1]
               [Child]
      [2]
         [Ghost]
      [3]
         [Node]
and so on.

Now it is impossible for me to easily use the structure, as I have to
ask every second level related record whether it is a Node or a Ghost.

In CakePHP original structure, I would simply use
$currentRecord[Ghost] and under there would be all the Ghosts :)

Does the above helps you to clarify why the original structure is
good?
Enjoy,
   John



On May 7, 10:05 am, Roland Bock <[email protected]> wrote:
> Hi,
>
> sorry to bring this up again, but I firmly believe that model data
> structure is inconsistent. I really don't get the current logic and
> haven't found any documentation explaining it.
>
> Suppose you have these models:
>
> class Parent extends AppModel
> {
>    var $hasMany = array('Node');}
>
> class Node extends AppModel
> {
>    var $hasMany = array('Child');
>
> }
>
> Then Parent->find yields something like:
>
> Array
> (
>     [0] => Array
>         (
>             [Parent] => Array
>                 (
>                     [id] => 7
>                 )
>
>             [Node] => Array
>                 (
>                     [0] => Array
>                         (
>                             [id] => 159
>                             [parent_id] => 7
>                             [Child] => Array
>                                 (
> [...]
>
> Essentially, the data structure is
>
> Parent
> Node
>   - Child
>
> I would expect it to be
>
> Parent
>    - Node
>         - Child
>
> I'd really like to understand why the data structure is as it is and/or
> how it can be changed to my expectations.
>
> Thanks and regards,
>
> Roland
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

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]
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

Reply via email to