DB_NestedSet::createRootNode() – Creates a new root node. If no id is specified then it is either added to the beginning/end of the tree based on the $pos.


require_once 'DB/NestedSet.php';

mixed DB_NestedSet::createRootNode ( array $values , integer $id = false , bool $first = false , string $pos = NESE_MOVE_AFTER )


Optionally it deletes the whole tree and creates one initial rootnode

 +-- root1 [target]
 +-- root2 [new]
 +-- root3


array $values

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

integer $id

ID of target node (the rootnode after which the node should be inserted)

boolean $first

Danger: Deletes and (re)inits the whole tree - sequences are reset

string $pos

The position in which to insert the new node.

Return value

returns The node id or false on error


throws no exceptions thrown


This function can not be called statically.


Create rootnodes

$nestedSet =& DB_NestedSet::factory('DB'$dsn$params);
$nestedSet->createRootNode(array('name' => 'rootnode'), falsetrue);
Creates a node after a given node (Previous) Creates a subnode (Next)
Last updated: Fri, 27 Nov 2015 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.