Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

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

Stars

7 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages