DB_NestedSet::moveTree() – Wrapper for node moving and copying


require_once 'DB/NestedSet.php';

int DB_NestedSet::moveTree ( int $id , $targetid , constant $pos , bool $copy = false , int $target )


This package is not documented yet.


integer $id

Source ID


Target ID

constant $pos

Position (use one of the NESE_MOVE_* constants)

boolean $copy

Shall we create a copy

integer $target

Target ID

Return value

returns ID of the moved node or false on error


see _moveInsideLevel

see _moveRoot2Root

see _moveAcross


throws no exceptions thrown


This function can not be called statically.


Get SubBranch

$nestedSet =& DB_NestedSet::factory('DB'$dsn$params);
$parent $nestedSet->createRootNode(array('name' => 'root-node'), falsetrue);
$parent2 $nestedSet->createSubNode($parent, array('name' => 'sub-node));
    $parent3 = $nestedSet->createSubNode($parent2, array('
name' => 'sub-node));
$nestedSet->createSubNode($parent3, array('name' => 'sub1'));
$node $nestedSet->createSubNode($parent3, array('name' => 'sub2'));
See if a given node is a parent of another given node (Previous) Fetch the data of a node with the given id (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:

Note by: ben@level8ds.com
Trees that are moved must be positioned "next to" (and not "beneath") existing nodes. As such, it is not possible to nest the source tree beneath a target node that has no existing children.

To clarify, valid targets for a move operation include leaves only; a branch (node with at least one child) is not a valid target.

One workaround is to create a new, temporary sub-node beneath the target, move the tree (using the temporary node as the target), and delete the temporary node once the move succeeds.