user2185041 user2185041 - 1 year ago 144
MySQL Question

CakePHP 2.3.1 updateAll query not working

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['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

Answer Source

See :

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

You can use


But, in your case, it would also work with the quoting:

"'" . date('Y-m-d H:i:s') . "'"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download