0
在CakePHP的博客教程在添加後add()
動作區間CakePHP的博客教程 - 控制器添加()動作
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.'));
}
}