We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Nested Sets AKA Modified Pre-order Tree Traversal


Implementation for laravel, maybe it is good time to start thinking about something like this in phalcon https://github.com/cartalyst/nesty

This is a very interesting pattern to include in the framework. I am sure we will but not sure which version. I am thinking maybe 1.1 or 1.2.

I am very glad that you think so too. I'm looking forward to it.


hi, for sure, a core implementation of uch a feature would be great, because who have never had to deal with data trees ? But, my two cents, adjacent tree and nested sets are two differents kind of approach. The first one is good if you have a lot of tree manipulation to do but is not appropriate for big trees. The second one is quiet ressources consumming when manipulating the tree, but is excellent for querying it. Morality: you will have to devellop these two approaches ;-)

BW, here are two php libraries for tree handling: nested sets: https://www.sideralis.org/baobab/index.html there's also a pear package : https://pear.php.net/manual/en/package.DB_NestedSet.php adjacent list: https://www.pdvictor.com/?sv=&category=just+code&title=adjacency+model


nested sets +1

Hi, Is any chance to implement in core of Phalcon MPTT pattern? Good explanation: https://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

+1 for tree behavior :)

this is my attempt to implementing MPTT pattern, there is still a lot work to do, love to hear ideas from you guys https://gist.github.com/bendo01/7014197

... I've never read this thread until now..so i've done an attempt of MPTT implementation too. u_u Here is my gihtub repository : https://github.com/lunaticPenguin/LeftRightTreeTraversal

Hope it can helps someone. I'm totally open minded to receive critics on my code (please do not hesitate). Otherwise Baobab seems to be really good.

-- Benny Leonard Enrico Panggabean> The first thing I can say about your work is that it's not really reusable for other projects or areas in your own project. I think if you did it generical, this would be cool ;) Also your code needs some comments.

@Corentin Legros thank you for sharing your code, and in reply to your comment, yes i will put some comments later on after testing it first, to put in generic i was confused to chose either to change it into traits or change it into behavior :)

I've ported last gist into behavior is not fully finish and still a lot work to do, I'm totally open minded to receive critics on my code (please do not hesitate). for details you can see it here : https://github.com/bendo01/Phalcon-TreeBehavior

+1 for nested set model. Multiple trees would be aweseome, too!