CakePHP 2.3.1 updateAll查询不起作用

use*_*041 1 php mysql cakephp cakephp-2.0

我无法更新CakePHP 2.3.1中的记录

查询:

$this -> Staff -> updateAll(array('Staff.last_login' => date('Y-m-d H:i:s')), array('Staff.id' => $staff['Staff']['id']));

错误:

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use

mar*_*ark 9

请参阅http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-updateall-array-fields-array-conditions:

The $fields array accepts SQL expressions. 
Literal values should be quoted manually using Sanitize::escape().
Run Code Online (Sandbox Code Playgroud)

您可以使用

NOW()
Run Code Online (Sandbox Code Playgroud)

但是,在您的情况下,它也适用于引用:

"'" . date('Y-m-d H:i:s') . "'"
Run Code Online (Sandbox Code Playgroud)