SkillAgentSearch skills...

NestedSets

Class for managing DB Tree

Install / Use

/learn @divampo/NestedSets
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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

View on GitHub
GitHub Stars7
CategoryDevelopment
Updated5y ago
Forks6

Languages

PHP

Security Score

70/100

Audited on Feb 8, 2021

No findings