Skip to content

Repository files navigation

Sweelix Node management

Sweelix node management is an implementation of Rational numbers to key nested sets by Dan Hazel (http://arxiv.org/abs/0806.3115).

Latest Stable VersionBuild StatusScrutinizer Code QualityCode CoverageLicense

Latest Development VersionBuild StatusScrutinizer Code QualityCode Coverage

Installation

If you use Packagist for installing packages, then you can update your composer.json like this :

{
"require": {
"sweelix/tree": "*"
}
}

Howto use it

Create a Node class and attach the NodeTrait to it. You can look at the class Node.

usesweelix\tree\NodeTrait;
class MyNode {
use NodeTrait;
}

Now you can create a node :

$node = newMyNode();
$node->setPath('1.2.1');
$leftBorder = $node->getLeft();
$rightBorder = $node->getRight();
$treeInfo = $node->getMatrix()->toArray();
// insert your node in DB using leftBorder and rightBorder// do not forget to also store the tree info

Now you can search the node in your DB using regular nested set methods :

# find all the childrenselect*from nodes where left > :nodeLeft and right < :nodeRight order by nodeLeft;
# find all the parentsselect*from nodes where left < :nodeLeft and right > :nodeRight order by nodeRight;

Contributing

All code contributions - including those of people having commit access - must go through a pull request and approved by a core developer before being merged. This is to ensure proper review of all the code.

Fork the project, create a feature branch , and send us a pull request.

About

Hazel Tree management for PHP

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages