我的代码是:
$this->Product->id = $product_range_detail['Product']['id'];
$product_neighbors_details = $this->Product->find('neighbors',array(
'conditions'=>array('Product.is_active'=>1,'Product.is_deleted'=>0,'Product.parent_id'=>0),
'order'=>'Product.display_order ASC',
'fields'=>array('id','name','slug','display_order'),
'value'=>$product_range_detail['Product']['id']
));
数组是这样的:
Array (
[prev] =>
[next] => Array (
[Product] => Array (
[id] => 130
[name] => Polyurethane Foam
[slug] => polyurethane-foam
[display_order] => 1
)
)
)
但是接下来我需要接下来的流行和流行。 我试图改变顺序,但它不起作用。
SQL查询也是这样的:
SELECT `Product`.`id`, `Product`.`name`, `Product`.`slug`,
`Product`.`display_order` FROM `mil_db`.`products` AS `Product`
WHERE `Product`.`is_active` = 1 AND `Product`.`is_deleted` = '0'
AND `Product`.`parent_id` = 0 AND `Product`.`id` < 124
ORDER BY `Product`.`id` DESC LIMIT 1
SELECT `Product`.`id`, `Product`.`name`, `Product`.`slug`,
`Product`.`display_order` FROM `mil_db`.`products` AS `Product`
WHERE `Product`.`is_active` = 1 AND `Product`.`is_deleted` = '0'
AND `Product`.`parent_id` = 0 AND `Product`.`id` > 124
ORDER BY `Product`.`id` ASC LIMIT 1
答案 0 :(得分:1)
最后5小时后我得到了解决方案:
$this->Product->id = $product_range_detail['Product']['id'];
$product_neighbors_details = array();
$product_neighbors_details = $this->Product->find('neighbors',array(
'conditions'=>array('Product.is_active'=>1,'Product.is_deleted'=>0,'Product.parent_id'=>$product_range_detail['Product']['parent_id']),
'order'=>array('Product.display_order'),
'fields'=>array('id','name','slug', 'display_order'),
'field' => 'display_order', 'value' => $product_range_detail['Product']['display_order']
));
实际上如果我没有设置字段值,那么默认情况下将php作为字段使用。