【发布时间】:2015-02-19 10:21:34
【问题描述】:
这是我开始学习 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());
}
【问题讨论】:
标签: cakephp cakephp-3.0