Searching for the best PHP nested sets class (PEAR class excluded)
Asked Answered
E

6

6

I'm looking for a PHP (with MYSQL) nested sets class with all needed functions. For example:

createLeftNode, createRightNode,createRootNode, createSubNode,deleteNode and moveTree. Not only 1 left, 1 right, 1 up and 1 down but also a part of a tree in a nother tree.

Thanks!

Ettore answered 7/11, 2008 at 13:4 Comment(0)
C
4

Well nested sets are great if you are working with hierarchical data. It's much more complex to implement it only with php arrays especially if you want to save these information in a database.

you could try this on. Never used it but after a short code screening it looks almost complete.

http://www.edutech.ch/contribution/nstrees/index.php

Catechize answered 7/11, 2008 at 13:48 Comment(1)
This library is not supported anymore, it seems there is new stuff on the 'market'. See my answer.Transversal
E
7

look at the nested behavior of Doctrine

Extract answered 7/11, 2008 at 14:27 Comment(0)
C
4

Well nested sets are great if you are working with hierarchical data. It's much more complex to implement it only with php arrays especially if you want to save these information in a database.

you could try this on. Never used it but after a short code screening it looks almost complete.

http://www.edutech.ch/contribution/nstrees/index.php

Catechize answered 7/11, 2008 at 13:48 Comment(1)
This library is not supported anymore, it seems there is new stuff on the 'market'. See my answer.Transversal
T
2

There is something new around: http://www.sideralis.org/baobab/


Old and outdated answer. The library is not supported anymore.

I used the nstrees library "buggzzy" posted (http://www.edutech.ch/contribution/nstrees/index.php) for a project where I had to give the user the possibility to create and edit the organisational chart of his company.

I like the "Modified Preorder Tree Traversal" algorithm very much but it seems to me that the nstree library is slow. In my case I have to iterate recursively down the tree. Maybe it's something else in my script which is slow.

Anyways I'm also still looking for an alternative and I recently checked the PEAR website and found a tree library there too: http://pear.php.net/package/Tree

The PEAR library didn't seem as comprehensive as NSTREE but I assume it could be more performant.

An article which helped me a lot with this question: Storing Hierarchical Data in a Database

Transversal answered 7/11, 2008 at 14:34 Comment(0)
T
1

Look at this library https://github.com/fpietka/Zend-Nested-Set : Implementation of a nested set model to use with Zend Framework

Tweak answered 23/1, 2012 at 20:34 Comment(1)
Can't find any docs and unit tests are not written yet. Last updated 2 year ago. Is this project abandoned?Valenzuela
D
0

It was long overdue, but I updated https://github.com/fpietka/Zend-Nested-Set (even with unit tests).

Drawn answered 29/8, 2014 at 14:57 Comment(0)
V
0

I wrote a nested set implementation that uses Doctrine DBAL as the database abstraction layer. Because we're using it with Drupal, it also tracks a revision_id.

https://github.com/previousnext/nested-set

Variance answered 6/2, 2017 at 20:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.