Cake3 ORM问题:有没有办法避免SQL字符串中的MySQL关键字错误?
我得到了一个" 1064你的SQL语法错误了#34;我尝试更新用户表时出错。
UPDATE users SET group = 'admin', modified = '2016-06-27 15:45:02' WHERE id = 2
如何将表名 users.group 添加到SQL字符串以避免关键字错误?
Controller.action(efault)
public function edit($id = null)
{
$user = $this->Users->get($id);
if ($this->request->is(['patch', 'post', 'put'])) {
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
$this->Flash->success(__('The Entry has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The Entry could not be saved. Please, try again.'));
}
}
$this->set(compact('user', 'contacts', 'userLists'));
$this->set('_serialize', ['user']);
}