本文介绍了CakePHP 2.3.1更新所有查询均不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法更新CakePHP 2.3.1中的记录
I am not able to update records in 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
推荐答案
请参见:
The $fields array accepts SQL expressions.
Literal values should be quoted manually using Sanitize::escape().
您可以使用
NOW()
但是,在您的情况下,也可以使用以下引号:
But, in your case, it would also work with the quoting:
"'" . date('Y-m-d H:i:s') . "'"
这篇关于CakePHP 2.3.1更新所有查询均不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!