我正在尝试在 CakePHP 中执行 SQL 更新。这是我的代码:
$sql = "
UPDATE carts
SET
qty = ".$this->data['Cart']['qty'].",
process = 'UnPaid'
WHERE ct_session_id = '".$this->data['Cart']['ct_session_id']."'
AND product_id = '".$this->passedArgs['pd_id']."'
AND key = '".$this->Session->read('Cart.key', $newCartkey)."'
";
$this->Cart->query($sql);
我收到此错误:
SQL Error: 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 near 'key = 'bwfgkxms'' at line 3
我的代码产生的查询是:
UPDATE carts
SET
qty = 111,
process = 'UnPaid'
WHERE ct_session_id = '3254430f577669bb8ecdb8b8aadf1b96'
AND product_id = '51'
AND key = 'bwfgkxms'