DB_NestedSet::createLeftNode() – Creates a node before a given node


require_once 'DB/NestedSet.php';

mixed DB_NestedSet::createLeftNode ( int $id , array $values , bool $returnID )


 +-- root1
 +-\ root2
 | |
 | |-- subnode2 [new]
 | |-- subnode1 [target]
 | |-- subnode3
 +-- root3


integer $id

Target node ID

array $values

Hash with param => value pairs of the node (see $this->params)

boolean $returnID

Tell the method to return a node id instead of an object. ATTENTION: That the method defaults to return an object instead of the node id has been overseen and is basically a bug. We have to keep this to maintain BC. You will have to set $returnID to TRUE to make it behave like the other creation methods. This flaw will get fixed with the next major version.

Return value

returns The node id or false on error


throws no exceptions thrown


This function can not be called statically.


Create left node

Firstly, we connect to NestedSet using Factory. Then we create some nodes and finally we create a LeftNode. The LeftNode will be placed leftsided to the first root-node.

$nestedSet =& DB_NestedSet::factory('DB'$dsn$params);
$parent $nestedSet->createRootNode(array('name' => 'root-node'), falsetrue);
$nestedSet->createSubNode($parent, array('name' => 'sub1'));
$nestedSet->createSubNode($parent, array('name' => 'sub2'));
$nestedSet->createLeftNode($parent, array('name' => 'left node'), true);
Convert a <1.3 tree into a 1.3 tree format (Previous) Creates a node after a given node (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.