On Jan 17, 7:54 pm, quentin <[email protected]> wrote:
> Hi AD7six
>
> Thanks for your answer.
>
> Yes I've realized my mistake.
> Off course it's a sql error and I was wrong when I though that this could
> come from the treeBehavior because as you said : "The tree behavior does
> not mix max() with other fields" and the other field come from another
> behavior that add fields.
>
> Again thanks you for your answer event if it's not a really interesting
> error ^^.
>
> last thing : I don't understand TreeBehavior isn't appropriate because
> menus can have many levels and I often read children's node. Do you use a
> simpler implementation?

In reality it will make little difference either way - except that the
tree behavior adds some complexity to development if it's not working
correctly as was the case for you.

However - unless your menu is incredibly complex (which would cause UI
problems) there simply isn't enough data for using the tree behavior
to make sense. IMO. To clarify what I meant: it is likely to be more
efficient to do:

    select * from menus where section = "main";

and pass the results into a nesting function which extracts the
subtree you want, than to do sub-tree queries on the menu - simply
because it's the same query always - the same cache hit no matter
which part of the menu you are rendering.

See this test case which demonstrates what I mean, and is something
I'll likely add to 2.1

https://github.com/AD7six/cakephp/blob/feature/set-nest/lib/Cake/Test/Case/Utility/SetTest.php#L3289

Unless there are other reasons to use the tree behavior - I wouldn't
choose to use it personally for menu data.

Also possibly worth pointing out this test, which demonstrates how I
convert flat data into nested uls with a menu helper:

https://github.com/AD7six/mi/blob/master/tests/cases/helpers/menu.test.php#L150

Note the use of the "under" key.

In any event, glad you found the cause for the wonky sql.

AD

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to