[英]How to get sorted array in dropbox in cakephp
I want sorted values in dropbox. 我想要在保管箱中排序值。 for that i have added this code which is given below.
为此,我添加了以下代码。 When i tried to add this code it is giving me error.
当我尝试添加此代码时,它给了我错误。 please help me out for this.
请帮我解决这个问题。
$zones = $this->{$this->modelClass}
->Zone->find("list", array('conditions' =>
array('is_active' => 1,'order' => array('name' => 'asc'))));
Error is given below
错误如下
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;
SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order = ('asc')' at line 1
检查与您的MySQL服务器版本相对应的手册,以在第1行的'order =('asc')'附近使用正确的语法
SQL Query: SQL查询:
SELECT `Zone`.`id`, `Zone`.`name`
FROM `develop_market_pulse`.`zones` AS `Zone`
WHERE `is_active` = '1'
AND order = ('asc')
Notice: If you want to customize this error message, create app\\View\\Errors\\pdo_error.ctp
注意:如果要自定义此错误消息,请创建app \\ View \\ Errors \\ pdo_error.ctp
The order
should not be in the conditions
: order
不应满足以下conditions
:
$zones = $this->{$this->modelClass}->Zone
->find("list", array(
'conditions' => array('is_active' => 1),
'order' => array('name' => 'asc')
));
Try this 尝试这个
$zones = $this->{$this->modelClass}->Zone->find("list", [
'conditions' => ['is_active' => 1],
'order' => ['name' => 'ASC']
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.