Object of class could not be converted to string |
Hi, guys I'm a (beginner) in CI4. Can anyone give me advice about this?
I'm trying to pass my getPost value to model, but it says that Object of class App\Models\Criteria could not be converted to string controller: [size=1][font=Consolas, 'Courier New', monospace] public function dataFilter(){ // Get Value on select id CatID $criteria = new Criteria(); $CatID = $this->request->getPost('CatID'); $details= $this->$criteria->fetchDataFilter($CatID); --------- Object of class App\Models\Criteria could not be converted to string[/font][/size] [size=1][font=Consolas, 'Courier New', monospace] $data['questions'] = $criteria->fetchDataFilter([size=1][font=Consolas, 'Courier New', monospace][size=1][font=Consolas, 'Courier New', monospace]$CatID[/font]); [/size] // return response to ajax return $this->response->setJSON($data); }[/font][/size] Model[/font][/size] [size=1][font=Consolas, 'Courier New', monospace] public function fetchDataFilter($CatID){ $CatID = $this->request->getPost('CatID'); $db = \Config\Database::connect(); $builder = $db->table('tblcriteria'); $builder->select('*'); $builder->join('tblcriteriadetail', 'tblcriteriadetail.CatID = tblcriteria.CatID'); $builder->where('tblcriteria.CatID', $CatID); $builder->where('tblcriteria.status', 1); $result = $builder->get()->getResult(); return $result; } }[/font][/size]
Your model returns an object. You try to store this object in the variable $details.
add a line before calling your model: $details = new stdClass(); Whoops, ignore that. That doesn't make sense. I guess I didn't have enough coffee there. |
Welcome Guest, Not a member yet? Register Sign In |