任何人都可以告诉我我收到错误:致命错误:在类中的此方法的非对象上调用成员函数fetch_assoc()
这是一个递归函数,它第一次运行正常,是我第二次收到错误。
function getSite($var, $var1 = 0, $numLevel = 1){
//get the page
$qry = "SELECT * FROM table WHERE columnA = $var AND columnB = $var1 ORDER BY parent, position ASC";
$arrPage = $this->my_sqli->query($qry);
//a valid resut was returned from the DB
while($obj = $arrPage->fetch_assoc()){
//add to array
if($obj['id']){
$this->arrMenu = array(
'id' => $obj['id'],
'parent' => $obj['parent'],
'level' => $numLevel
);
... some more code
// call the function again
getSite($value1);
}
}
}
答案 0 :(得分:0)
通常当我看到这些错误时,查询出现问题,请尝试回显查询并在查询浏览器中执行
答案 1 :(得分:0)
您不包括错误检查。
更改
$arrPage = $this->my_sqli->query($qry);
到
if ( ($arrPage = $this->my_sqli->query($qry)) === false) {
printf("Error: %s in query %s\n", $this->my_sqli->error,$qry);
}