(08-10-2015, 03:44 PM)shaheb Wrote: Hi, I am facing strange issue.
My model have a result from DB, when I debug it in model it gives me result but when I return it to controller it gives empty object. any suggestion ?
HERE is my Controller code
function editCompanyForm($companyId) {
$this->load->model('Company');
$company = $this->Company->getCompanyById($companyId);
debug($company);exit; it gives me nothing
$data["company"] = $company;
$this->load->view('admin/companyForm',$data);
}
here is my Model code
function getCompanyById($id) {
$this->db->where('company_id',$id);
$query = $this->db->get('companies');
debug($query->row());/// it gives me object
if ( $query->num_rows == 1 ) {
return $query->row();
} else {
return false;
}
}
In your model code $query->num_rows() is a method. So it must be followed by parentheses.