I am using the code below to query the database, but it is giving the following error:
PHP Error was encountered Severity: Notice Message: Undefined property: Admin :: $ db Filename: core / Model.php Line Number: 51
Fatal error: Call to a member function query () on a non-object in /home/*/public_html/application/models/admin_model.php on line 4 **
Code
class Admin_model extends CI_Model {
public function carregar_hoteis(){
$hoteis = $this->db->query("SELECT * FROM tabela");
$array=array();
foreach($hoteis->result() as $row)
{
$array['hoteis'][]=$row;
}
echo json_encode($array);
}
}