【发布时间】:2020-09-15 17:45:54
【问题描述】:
我有数组 $productsTop
(int) 0 => '6
(int) 1 => '4',
(int) 2 => '1',
(int) 3 => '2',
(int) 4 => '3',
(int) 5 => '5'
其中 6 4 1 2 3 5 是产品表的 id。 我只想显示我的产品表中的 5 种产品,但不按 ID ASC 或 DSC 订购, 我想按 ID 订购它们,就像它们在 arrar 中订购的一样,所以它可以首先显示产品 ID 6,然后是 ID 4...到 ID 5。
有人可以帮忙吗?
$productTop = [6,4,1,2,3,5];
$product = $this->Product->find('all', array(
'conditions'=>array('Product.id'=>$productTop),
'limit'=>5
));
通过这种方式,它向我显示所有产品,但按其 ID 排序,而不是向我显示:
6,4,1,2,3,5
它显示:
1,2,3,4,5,6
【问题讨论】: