请问,如何解决以下错误?
致命错误:在非对象上调用成员函数fetch_assoc() 在......
database.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
会导致“致命错误”。