【发布时间】:2013-12-14 02:06:37
【问题描述】:
在 cakephp 博客教程中添加帖子add() 操作部分
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html
我不明白这个$this->Post->create(); 做了什么,我试图删除那行代码,它仍然可以正常工作。那行代码是做什么的?
public function add() {
if ($this->request->is('post')) {
$this->Post->create();
if ($this->Post->save($this->request->data)) {
$this->Session->setFlash(__('Your post has been saved.'));
return $this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(__('Unable to add your post.'));
}
}
【问题讨论】:
标签: php cakephp cakephp-2.0