DB_NestedSet::createRightNode

DB_NestedSet::createRightNode() – Creates a node after a given node

Synopsis

require_once 'DB/NestedSet.php';

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

Description

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

Parameter

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

throws no exceptions thrown

Note

This function can not be called statically.

Example

Create right node

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

<?php
require_once('DB/NestedSet.php');
    
$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->createRightNode($parent, array('name' => 'right node'), true);
?>
Creates a node before a given node (Previous) 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. (Next)
Last updated: Fri, 18 Apr 2014 — 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.