I have this method called treetrunk() that runs up a parent child relationship and is supposed to return an array if ids as a "branchPath" - the method seems to be working just fine as a var_dump() call in my terminating condition shows the proper array. However if I try to call the method the returned array is "NULL" - I really don't get it.
Model method:
function treeTrunk($id){ if ($id == '0') { var_dump($this->branchPath); //this shows perfect array return $this->branchPath; //this returns null } else { $q = $this->getWhere(array('id' => $id), null, null); array_push($this->branchPath, $q[0]['pageParent']); $this->treeTrunk($q[0]['pageParent']); } }Calling via controller:
$d = $this->pages_mdl->treeTrunk('150');var_dump($d); // <- this == NULLvar_dump() from within the method outputs:
array(3) { [0]=> string(3) "148" [1]=> string(3) "146" [2]=> string(1) "0"}