Class for managing DB Tree
Copyright (c) 2012 Dmitry Serpakov
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
PHP 5.3+
ORM
- another implementation of the NestedSets algoritm
Create DB:
#!=shell
$ mysql -u USERNAME -p DATABASE < db.sql
Include libraries:
#!=PHP
require_once 'ORM.class.php';
require_once 'NestedSets.class.php';
Try to use:
#!=PHP
$ORM = new ORM(); // your own ORM
$NestedSets = new NestedSets($ORM, 'db_tree');
$NestedSets->insert(1, array('name' => 'First'));
-
getTree() - Get whole tree
-
getBranch() - Get current branch
-
getPath() - Get path to current item (current included)
-
getDescendants() - Get descendants for current
-
getChilds() - Get child for current
-
insert() - Insert new item
-
delete() - Delete current item WITH ALL DESCENDANTS
-
moveUnder() - Move current item to the subordinate of parent
-
moveNear() - Move current item near
-
move() - Move current item process