I'm trying to pass an array to a view from a controller but I can't and I don't know why.
I have a model, a controller and a view.
The model:
<?php
class Modelo_bd extends CI_Model
{
public function datos()
{
$cnb=$this->db->query("SELECT * from anuncios");
return $cnb->result();
}
}
?>
The controller:
if($this->modelo_usuarios->puede_entrar($usr))
{
$this->load->model("modelo_bd");
$cbd=$this->modelo_bd->datos();
$this->load->view('datos',$cbd);
return true;
}
The view:
<?php
echo $cbd->titulo_a;
echo $cbd->contenido;
?>
The error is in the view.
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: cbd
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Why $cbd variable isn't recognized in the view if it is an array? How can I fix it?
Thanks.