$resData = (new \yii\db\Query())
->select('*')
->from('product')
->where(['id' => $productIdsArray])
->all();
//查出的结果是升序排列的要想实现指定数组内的排序顺序可以使用下面的方法
$productIds = implode(',' , $productIdsArray);
$orderBy = (new \yii\db\Query())
->select('*')
->from('product')
->where(['id' => $productIdsArray])
->orderBy([new \yii\db\Expression("FIELD (id, $productIds)")])
->all();
yii2 in 集合查询排序失效解决方法
最新推荐文章于 2024-03-16 17:07:08 发布