小编jus*_*ohu的帖子

CakePHP 3实体混乱

这是我开始学习CakePHP 3以来一直面临的问题

实体的这个概念是什么,现实世界的例子会有所帮助.

public function add()
{
            // why do we have to create new entity / what is the role of entity here. 
    $comment = $this->Comments->newEntity();

    if ($this->request->is('post','put')) {

                    // why do we have to use this line after posting / what is the role of this line. 

        $comment = $this->Comments->patchEntity($comment,$this->request->data);

        if ($this->Comments->save($comment)) {
            $this->Flash->success('comment submitted successfully.');
        } else {
            $this->Flash->error('Sorry, comment could not be updated.');
        }
    }

    return $this->redirect($this->referer());
}
Run Code Online (Sandbox Code Playgroud)

cakephp cakephp-3.0

3
推荐指数
1
解决办法
4748
查看次数

标签 统计

cakephp ×1

cakephp-3.0 ×1