DB_NestedSet::getParent() – Fetch the immediate parent of a node given by id


require_once 'DB/NestedSet.php';

mixed DB_NestedSet::getParent ( int $id , bool $keepAsArray = false , bool $aliasFields = true , array $addSQL = array() , $useDB = true )


This package is not documented yet.


integer $id

The node ID

boolean $keepAsArray

(optional) Keep the result as an array or transform it into a set of DB_NestedSet_Node objects?

boolean $aliasFields

(optional) Should we alias the fields so they are the names of the parameter keys, or leave them as is?

array $addSQL

(optional) Array of additional params to pass to the query.


Return value

returns False on error, or the parent node


see _addSQL


throws no exceptions thrown


This function can not be called statically.


Get Parent

Fetch the immediate parent of a node given by id. GetParent will return $parent2 as $data.

$nestedSet =& DB_NestedSet::factory('DB'$dsn$params);
$parent $nestedSet->createRootNode(array('name' => 'root-node'), falsetrue);
$parent2 $nestedSet->createSubNode($parent, array('name' => 'sub-node));
    $nestedSet->createSubNode($parent2, array('
name' => 'sub1'));
    $nestedSet->createSubNode($parent2, array('
name' => 'sub2'));
    $data = $nestedSet->getParent($parent2);
Fetch the children _one level_ after of a node given by id (Previous) Fetch the parents of a node given by id (Next)
Last updated: Fri, 29 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:

There are no user contributed notes for this page.