【发布时间】:2015-04-01 07:58:30
【问题描述】:
我正在使用 CakePHP 3.0 开发一个新项目。
我正在使用身份验证组件,每当用户登录时,我都会更新字段 visited 的值。
UsersController:
public function login() {
if ($this->request->is('post')) {
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
$this->Users->setVisited($user['id']);
return $this->redirect($this->Auth->redirectUrl());
}
$this->Flash->error('Your username or password is incorrect.');
}
}
用户表:
public function setVisited($id) {
$user = $this->findById($id)->first();
$user->visited = Time::now();
if($this->save($user)) {
return true;
}
return false;
}
现在,我想保存而不更新字段modified 的值。我已经尝试过以前版本的 cake 中使用的方法:
$user->modified = false;
它不起作用,抛出和错误:Call to a member function format() on a non-object 因为我猜日期时间字段现在被视为对象。
任何帮助将不胜感激,
保罗
【问题讨论】:
标签: cakephp cakephp-3.0