hit*_*han 8 cakephp cakephp-3.0
我开始只是好奇地使用CakePHP3.0.为了熟悉CakePHP3.0的新功能,我在官方网站(http://book.cakephp.org/3.0/en/tutorials-and-examples/blog/blog.html)上关注了博客教程.我所做的只是复制和过去的源代码.一切正常,除了"创建"和"修改"字段没有保存.他们只是保持NULL.我已经确认这个功能在CakePHP 2.4.6中运行良好.下面是博客教程的表定义和函数add().
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"));
}
Run Code Online (Sandbox Code Playgroud)