Wednesday, May 5, 2010

Re: Structure of data returned by $this->Model->find

>> As you can see, Leaf is sometimes on the same level as its parent,
>> sometimes it is included. Same happens with Node.
>>
>> This is an inconsistent structure...
>
> You realize that's an incredibly inefficient way to query your data I
> hope - and it looks fine to me "..."

Associated data is
*) at the same level as the element, in case of the root element
*) included in the element, otherwise

That is inconsistent as far as I can see (or am I missing something?)

I was just using this as an example to demonstrate the inconsistency
with as little code as possible. It also applies to other nested
(non-tree) structures. For instance

class Parent extends AppModel
{
var $hasMany = array('Node');
}
class Node extends AppModel
{
var $hasMany = array('Child');
}

Array
(
[0] => Array
(
[Parent] => Array
(
[id] => 7
)

[Node] => Array
(
[0] => Array
(
[id] => 159
[parent_id] => 7
[Child] => Array
(
[...]

Parent and Node are at the same level.
Child is contained in Node.

But since the relationship between Parent and Node is the same as
between Node and Child I would expect the same for the data structure.


Thanks and regards,

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: