Welcome Guest, Not a member yet? Register   Sign In
Object of class could not be converted to string
#1

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]  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
[/size]

[size=1]
        $data['questions'] = $criteria->fetchDataFilter([size=1][size=1]$CatID
);
     
[/size]        // return response to ajax
        return $this->response->setJSON($data);
    }
[/size]


Model
[/size]

[size=1] 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;

    }



    }
[/size]
Reply


Messages In This Thread
Object of class could not be converted to string - by jundavewamar - 07-27-2022, 08:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB