我開始只是好奇使用CakePHP3.0設置。 要使用CakePHP3.0的熟悉新功能我自己,我也跟着在官方網站(http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/blog.html)的博客教程。我所做的只是在那裏複製和過去的源代碼。 一切工作正常,除了字段「創建」和「修改」不被保存。他們只是保持NULL。我已經確認這個特性在CakePHP 2.4.6中工作正常。以下是博客教程的表格定義和函數add()。字段「創建」和「修改」不會自動CakePHP3.0.0(開發預覽2)
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(50),
body TEXT,
created DATETIME DEFAULT NULL,
modified DATETIME DEFAULT NULL
);
public function add(){
$article = $this->Articles->newEntity($this->request->data);
if($this->request->is("post")){
if($this->Articles->save($article)){
$this->Session->setFlash("Success!");
return $this->redirect(["action"=>"index"]);
}
$this->Session->setFlash("Fail!");
}
$this->set(compact("article"));
}
謝謝!它工作得很好......我應該更徹底地搜索它。 – hitochan