Skip to content

kunx-edu/NestedSets

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NestedSets

Class for managing DB Tree

Copyright (c) 2012 Dmitry Serpakov

Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)

Dependence

PHP 5.3+

ORM

Highlights

  • another implementation of the NestedSets algoritm

Basic usage

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'));

Methods

  • 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

About

Class for managing DB Tree

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%