是否可以在Cakephp模型的表方法中执行保存操作?

是否可以在Cakephp模型的表方法中执行保存操作?,php,cakephp,Php,Cakephp,例如,我的控制器中有: public function add() { $bookmark = $this->Bookmarks->newEntity(); if ($this->request->is('post')) { $bookmark = $this->Bookmarks->patchEntity($bookmark, $this->request->data);

例如,我的控制器中有:

public function add()
    {
        $bookmark = $this->Bookmarks->newEntity();
        if ($this->request->is('post')) {
            $bookmark = $this->Bookmarks->patchEntity($bookmark, $this->request->data);
            $bookmark->user_id = $this->Auth->user('id');
            if ($this->Bookmarks->save($bookmark)) {
                $this->Flash->success('The bookmark has been saved.');
                return $this->redirect(['action' => 'index']);
            }
            $this->Flash->error('The bookmark could not be saved. Please, try again.');
        }
        $tags = $this->Bookmarks->Tags->find('list');
        $this->set(compact('bookmark', 'tags'));
        $this->set('_serialize', ['bookmark']);
    }

是否可以在模型表方法中执行保存操作/方法?

您是否尝试过此代码。如果是的话,你会犯什么错误?不,我还没有试过,我想问问是否有人必须看看这是否可能。