我正在尝试在Paginator助手的蛋糕PHP分页功能中使用条件和顺序
这是我正在使用的代码
$this->set('equipment', $this->Paginator->paginate('Equipment',array('conditions' => array('Equipment.equipment_type_id' => 19), 'order' => array('Equipment.problem_count', 'Equipment.barcode DESC'))));
但它给了我这个错误
错误:SQLSTATE [42S22]:找不到列:1054'where子句'中的未知列'条件'
SQL查询:SELECT Equipment
。id
,Equipment
。equipment_type_id
,Equipment
。barcode
,Equipment
。{ {1}},problem_count
。Equipment
,description
。Equipment
,created
。Equipment
,modified
。{{1 },EquipmentType
。id
,EquipmentType
。name
,EquipmentType
。created
FROM EquipmentType
。modified
AS unlibike
LEFT JOIN equipment
。Equipment
AS unlibike
ON(equipment_types
。EquipmentType
= Equipment
。equipment_type_id
)WHERE条件=(19)AND EquipmentType
IN('Equipment.problem_count','Equipment.barcode DESC')LIMIT 20
通过查看生成的SQL查询,看起来Cake PHP正在将“条件”和“订单”解释为列。
任何人都可以帮助我吗?
答案 0 :(得分:1)
按Paginator :: paginate
的顺序排列* @param Model|string $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel')
* @param string|array $scope Additional find conditions to use while paginating
* @param array $whitelist List of allowed fields for ordering. This allows you to prevent ordering
* on non-indexed, or undesirable columns. See PaginatorComponent::validateSort() for additional details
* on how the whitelisting and sort field validation works.
http://api.cakephp.org/2.6/class-PaginatorComponent.html#_paginate
示例:
$this->Paginator->settings = array(
'order'=>array('yourfields');
);
$this->Pagniator->paginate('Equipment', $conditionsArray ) ;