SELECT rows from database based on optionally provided id in a CodeIgniter model method
15:49 02 Jul 2016

I need to make an appointment through the session (id).

My Model:

public function get_all($id = NULL)
{
    if ($id != NULL):
        $id = $this->session->userdata($id);
        $this->db->where('id_user', $id);
        $this->db->like('tipo_user', 'inquilino');
        return $this->db->get('users');
    endif;
}

My View:

$query = $this->sindico->get_all()->result();  

I need to show all residents who belong to the liquidator

Example of how it would be my query:

select * from user where id_user = 1 and tipo_user = "%residents%"

When performing this error appears:

Fatal error: Call to a member function result() on a non-object in

php codeigniter model-view-controller codeigniter-2 session-state