I have a problem when fetching data from database. How can I fix this? My code:
class Disaster_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->table = 'disasters';
}
public function lists()
{
$data = $this->db->get($this->table);
return json_encode($data->result());
}
}
The errors are:
Undefined property: Disaster::$db
and
Call to a member function get() on null
private $table = 'disastersthen access it via$data = $this->db->get($this->table);database.php.