views:

2981

answers:

7

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!

A: 

why so difficult if you have the array_push, array_pop and array_slice functions ?

in php you dont NEED sets. the array is the ultimate set / hash / linkedlist / whatever you want to name it.

SchizoDuckie
how would you use the mentioned array functions for hierarchical data?
tharkun
This question is not about sets vs. arrays, but about a hierarchical structure using the "nested set" method.
Jan Fabry
+3  A: 

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

+5  A: 

look at php Doctrine . http://www.doctrine-project.org/Doctrine_Node_NestedSet/1_0

Tom Haigh
A: 

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

tharkun
A: 

Php Cat Nested Set Model Mysql Tree Class

Look at my package at http://deveploper.bloggum.com

A: 

Im looking too good php class but it must work with eAccelerator or memcached any idea ?

greetings, jacek from http://www.forum.wiaderko.com/

A: 

Where did you end up with this? Did you find a favorite? I'm looking for one as well and it must support multiple roots. Why did you exclude the pear lib?

Doug