PHP code example of previousnext / nested-set

1. Go to this page and download the library: Download previousnext/nested-set library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

previousnext / nested-set example snippets


$schema = new DbalNestedSetSchema($connection, 'my_tree');
schema->create();

$nestedSet = new DbalNestedSet($connection, 'my_tree');

$nodeKey = new NodeKey($id, $revisionId);
$rootNode = $nestedSet->addRootNode($nodeKey);

$nodeKey = new NodeKey($id, $revisionId);
$nestedSet->addNodeBelow($rootNode, $nodeKey);

$nodeKey = new NodeKey($id, $revisionId);
$descendants = $this->nestedSet->findDescendants($nodeKey);

$nodeKey = new NodeKey($id, $revisionId);
$ancestors = $this->nestedSet->findAncestors($nodeKey);

make lint-php

make fix-php