4 mysql cakephp mysql-error-1064
我想使用created表格中的字段检索cakephp中的最后3个注册用户Users.
在我的控制器中我有:
$this->User->recursive = 1;
$this->set('users',
$this->User->find('all',
array('conditions'=> array(
'limit' => 3,
'order' => array(
'created' => 'asc'
)
)
)
)
);
Run Code Online (Sandbox Code Playgroud)
运行时上面的代码返回此错误:
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 'order = ('asc')' at line
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能解决错误?
尝试这样的事情:
$this->set('users', $this->User->find('all', array(
'limit' => 3,
'order' => 'User.created DESC',
'recursive' => 1,
)));
Run Code Online (Sandbox Code Playgroud)