Php 致命错误:调用未定义的方法

Php 致命错误:调用未定义的方法,php,Php,我犯了这个错误 致命错误:在第128行调用未定义的方法RecursiveArrayInterator::fetch_array() $hierachy = new hierachy; $iterator = new RecursiveIteratorIterator(new recursiveArrayIterator($hierachy->getSamelevelNode($name1))); try { while($row = $iterator-&g

我犯了这个错误

致命错误:在第128行调用未定义的方法RecursiveArrayInterator::fetch_array()

$hierachy = new hierachy;
    $iterator = new RecursiveIteratorIterator(new recursiveArrayIterator($hierachy->getSamelevelNode($name1)));
    try {
        while($row = $iterator->fetch_array()) {  //line where error is coming from 128
      if(!isset($targ)) {
       $targ = $row['left_node']+1; 
      }
      if($row['left_node'] == $targ) { 
        echo $row['name'];
        $targ = $row['right_node']+1; 
      }
    } 

因为没有这样的方法:

您的代码在这里也有不匹配的大括号。您有四个
{
,只有三个
}
@Bacon位:显然他没有用“lost”粘贴
catch
部分
}
我认为函数与类和方法的安装之间存在某种类型的输入错误。@HPDeveloper:在我更正了递归数组迭代器之后,没有您的更正,我的答案已经足够好了this@fello:如果您有工作代码,为什么要将其更改为错误?这是函数和公共函数getSamelevelNode()上面的实例化({$stmt=conn::getInstance()->prepare(“SELECT*FROM categories WHERE left_node=right_node”);$stmt->execute();return$stmt->fetchALL(PDO::FETCH_ASSOC);}