I'm very new to CodeIgniter and not an expert in OOP so please bear with me.
This is the function I have in my model:
function get_company(int $user_id, $fields = '*'){
$r = $this->db->query("SELECT $fields FROM ".$this->db->dbprefix('companies')." WHERE user_id=?", $user_id)->row();
return $r;
}
function get_profile($user_id, $fields = '*'){
$r = $this->db->query("SELECT $fields FROM ".$this->db->dbprefix('users_profiles')." WHERE user_id=?", $user_id)->row();
return $r;
}
This is in my controller that is calling that model:
function index(){
$this->load->model('profiles_m');
$profile = $this->profiles_m->get_profile($this->access->getUid());
$company = $this->profile_m->get_company($this->access->getUid());
$vars = array(
'profile'=>$profile,
'company'=>$company,
);
$this->_getTemplate()->build('account', $vars);
}
An in my view:
$company = array(
'name' => 'company',
'id' => 'company',
'value' => "$company->name",
'class' => 'styl_f validate[required] text-input input-xlarge',
'placeholder' => "$company->name"
);
echo $company['value']
The error I am getting is this: Call to a member function get_company() on a non-object in C:\..\application\modules\accounts\controllers\accounts.php
I am under the impression that I am receiving these errors because I am passing a non object through get_company() but the thing that confuses me is that this error does not come up for get_profile(); The get_profile() function in my model is very similiar to my get_company() function. What is causing this error? How can I get rid of it?