请问,下面的错误怎么解决?
致命错误:在非对象中调用成员函数 fetch_assoc()
数据库.php
protected function get_results_from_query() {
$this->open_connection();
$result = $this->conn->query($this->query);
while ($this->rows[] = $result->fetch_assoc());
$result->close();
$this->close_connection();
array_pop($this->rows);
}
usuario.php
public function getUsers(){
//$this->query variable define in class abstract database
$this->query = " SELECT * FROM Usuario LIMIT 0, 30";
$this->get_results_from_query();
}
一切正常,但调用function getUsers
会导致“致命错误”。