Using a while loop with objective oriented php programming
<p>I am using the for each below with objective         </p>

<pre><code>$hierachy = new hierachy;
$iterator = new RecursiveIteratorIterator(new recursiveArrayIterator($hierachy-&gt;getSamelevelNode($name1)));
try {
   while($row = $hierachy-&gt;getSamelevelNode($name1)) {
  if(!isset($name1)) {
   $name1 = $row['left_node']+1; // First row = the node we searched from. First child's lft = lft+1.
  }
  if($row['left_node'] == $name1) { //This is a child of the searched node.
    echo $row['name'];
    $name1 = $row['right_node']+1; //next child's lft = this child's rgt + 1.
  }
} 

    }
catch(Exception $e)
    {
    echo $e-&gt;getMessage();
    }
</code></pre>

<p>I don't have a fecht_Array function inside the functions.php I want to know how can I connect the function below with the while loop above with the function below.</p>

<pre><code>    public function getSamelevelNode($node_name){
$stmt = conn::getInstance()-&gt;prepare("SELECT name,left_node,right_node
FROM categories
WHERE left_node = right_node AND name = :node_name
");
$stmt-&gt;bindParam(':node_name', $node_name, PDO::PARAM_STR);

$stmt-&gt;execute();
return $stmt-&gt;fetchALL(PDO::FETCH_ASSOC);
}
</code></pre>

<p>right now I am having trouble to know what function from the function in the while loop can be used to Fetch the data. I tried fetchALL but it seems. </p>

<p>In other words my function and the while loop are not working together. </p>
