tiaguinho / mongodb-cakephp3

An Mongodb datasource for CakePHP 3.0
MIT License
28 stars 29 forks source link

Unable to run save query #34

Open anubhav-wedig opened 3 years ago

anubhav-wedig commented 3 years ago

I wanted to use this plugin with y setup of CakePHP 3.8 but I am unable to run the save data query.

This is my save method in the controller: `$admin = $this->Admins->newEntity();

    if ($this->request->is('post')) {
        $admin = $this->Admins->patchEntity($admin, $this->request->getData());

        if ($this->Admins->save($admin)) {
            $this->Flash->success(__('The admin has been saved.'));

            $response = array('success' => true, 'msg' => "success");
        } else {
            $this->Flash->error(__('The page could not be saved. Please, try again.'));

            $response = array('success' => false, 'msg' =>"error");
        }

        echo json_encode($response);
        die;
    }`

Commenting this line in the save function mentioned in the "hayko\mongodb\src\ORM\Table.php" $entity->isNew() ? RulesChecker::CREATE : RulesChecker::UPDATE Did make it work but I am not sure if it's the right way.

The error I get is "Call to a member function select() on array". Please help me with it ASAP.