More DB_NestedSet

Daniel Khan, one of the maintainers of PEAR::DB_NestedSet jumped in and offered help after my last post on the subject of that package. It turned out there was a bug in the file Menu.php within the current version of NestedSet which is now fixed in CVS. Once that change was made it turned out there were still a few bugs in my code to be worked out.

With everything fixed I can now access menus as I would wish.

To retrieve all nodes: $data = $nestedSet->getAllNodes(true)

NestedSet supports multiple trees in one database table, each with their own parent. To retrieve all nodes within the tree that $id is a member of: $data = $nestedSet->getBranch($id, true);

And to get all the descendants of $id: $data = $nestedSet->getSubBranch($id,true);

It’s definitely making my menu handling much easier. I’m still working out how best to integrate functions to move and delete nodes with my admin tools and once I’m done I’ll try and write up a few examples here.

Tags: , ,

Comments are closed.