DB_NestedSet::moveTree

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

Synopsis

require_once 'DB/NestedSet.php';

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

Description

This package is not documented yet.

Parameter

integer $id

Source ID

$targetid

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

see _moveInsideLevel

see _moveRoot2Root

see _moveAcross

Throws

throws no exceptions thrown

Note

This function can not be called statically.

Example

Get SubBranch

<?php
require_once('DB/NestedSet.php');
    
$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'));
    
$nestedSet->moveTree($node$parentNESE_MOVE_AFTER);
?>
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: Fri, 01 Aug 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:

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.