如何解决CakePHP分页给出“ Limit 20 Offset 0”错误
我正试图吸引所有用户,而我正在为此使用分页。
public function index()
{
$this->paginate = [
'contain' => ['Groups']
];
$users = $this->paginate($this->Users);
$this->set(compact('users'));
$this->set('_serialize',['users']);
}
但是在$this->paginate
之后,我得到了
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 near 'groups Groups ON Groups.id = (Users.group_id) LIMIT 20 OFFSET 0' at line 1
找不到造成此问题的原因。
有人知道我为什么遇到这个问题吗?
解决方法
您必须将表重命名为组。从v8开始,这是保留字。您可以在此处查看有关保留字的更多详细信息:https://dev.mysql.com/doc/refman/8.0/en/keywords.html
另一种解决方案可能是将保留字包裹在`(带有重音符号)
中版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。