PHP Classes
elePHPant
Icontem

Nested Sets DB Tree: Manipulate database records in hierarchical trees

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2015-07-22 (1 year ago) RSS 2.0 feedStarStarStarStar 74%Total: 7,313 This week: 2All time: 250 This week: 406Down
Version License PHP version Categories
dbtree 4.4GNU General Publi...5Databases, Data types
Description Author

This class can be used to manipulate nested sets of database table records as an hierarchical tree.

It can initialize a tree, insert nodes in specific positions of the tree, retrieve node and it's parent records, change nodes position and delete nodes.

Currently the class functions can:

- Retrieve all data for node with number node id
- Retrieve data of closest parent for node with number node id
- Add new child element to node with number parent id
- Add a new element into the tree near node with number node id
- Assigns another parent parent id to a node node id with all its children
- Change position of nodes within the same parent and same level of nesting
- Swapping nodes with it's children within the same parent and same level of nesting
- Deletes element with number node id from the tree without deleting it's children, moving its children up one level
- Deletes element with number node id from the tree and all it children.
- Returns all elements of the tree sorted by left value
- Returns all elements of a branch starting from an element with number node id
- Returns all parents of element with number node id
- Returns a slightly opened tree from an element with number node id
- Sort children in a tree for order field in alphabetical order
- Makes UL/LI HTML from nested sets tree with links if needed

Name: Kuzma Feskov <contact>
Classes: 1 package by
Country: Russian Federation Russian Federation
Age: 40
All time rank: 3528 in Russian Federation Russian Federation
Week rank: 369 Down15 in Russian Federation Russian Federation Down

Details

DbTree - Nested Sets

This class can be used to manipulate nested sets of database table records as an hierarchical tree.

It can initialize a tree, insert nodes in specific positions of the tree, retrieve node and it's parent records, change nodes position and delete nodes..

This source file is part of the SESMIK CMS.

Methods:

  • GetNode - Receive all data for node with number $nodeId.
  • GetParent - Receive data of closest parent for node with number $nodeId.
  • Insert - Add new child element to node with number $parentId.
  • InsertNear - Add a new element into the tree near node with number $nodeId.
  • MoveAll - Assigns another parent ($parentId) to a node ($nodeId) with all its children.
  • ChangePosition - Change position of nodes. Nodes have to have same parent and same level of nesting.
  • ChangePositionAll - Swapping nodes with it's children. Nodes have to have same parent and same level of nesting. $nodeId1 can be placed "before" or "after" $nodeId2.
  • Delete - Deletes element with number $nodeId from the tree without deleting it's children. All it's children will move up one level.
  • DeleteAll - Deletes element with number $nodeId from the tree and all it children.
  • Full - Returns all elements of the tree sorted by "left".
  • Branch - Returns all elements of a branch starting from an element with number $nodeId.
  • Parents - Returns all parents of element with number $nodeId.
  • Ajar - Returns a slightly opened tree from an element with number $nodeId.
  • SortChildren - Sort children in a tree for $orderField in alphabetical order.
  • MakeUlList - Makes UL/LI html from nested sets tree with links (if needed). UL id named as table_name + _tree.

History

  • v4.4 - MakeUlList modified
  • v4.3 - Added new method MakeUlList
  • v4.2 - added fully functional demo samples
  • v4.1 - added new method SortChildren

russian dicumentation http://www.sesmikcms.ru/pages/read/biblioteka-dlja-raboty-s-derevjami-nested-sets/

Author Kuzma Feskov <kfeskov@gmail.com>

Copyright © 2015, Kuzma Feskov

Screenshots  
  • dbtree_manage
  Files folder image Files  
File Role Description
Files folder imageexamples (3 files)
Files folder imagelanguage (2 files)
Plain text file DbTree.class.php Class DbTree v4.4
Plain text file DbTreeExt.class.php Class DbTree v4.4
Plain text file README.md Doc. Documentation
Plain text file safemysql.class.php Class Class source

  Files folder image Files  /  examples  
File Role Description
  Plain text file dbtree_demo.php Example Example script
  Plain text file dbtree_visual_demo.php Example Example script
  Plain text file sample_dump.sql Example MySQL dump of demo

  Files folder image Files  /  language  
File Role Description
  Plain text file dbtree.lang-en.php Class Class source
  Plain text file dbtree.lang-ru.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 90%
Total:7,313
This week:2
All time:250
This week:406Down
User Ratings User Comments (1)
 All time
Utility:98%StarStarStarStarStar
Consistency:82%StarStarStarStarStar
Documentation:80%StarStarStarStarStar
Examples:89%StarStarStarStarStar
Tests:-
Videos:-
Overall:74%StarStarStarStar
Rank:146