![]() |
model is not return data to controller. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: model is not return data to controller. (/showthread.php?tid=62654) |
model is not return data to controller. - shaheb - 08-10-2015 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; } } RE: model is not return data to controller. - pdthinh - 08-10-2015 (08-10-2015, 03:44 PM)shaheb Wrote: Hi, I am facing strange issue. In your model code $query->num_rows() is a method. So it must be followed by parentheses. RE: model is not return data to controller. - shaheb - 08-11-2015 thanks man, it solved, previously Ii was let me check like this. |