I got this problem and not found any solution with yii instrument. Someone know how to solve this problem ?
Eventually, i used this bad code
$params = [];
foreach ($recipeIds as $i => $recipeId) {
$params[':id_'.$i] = $recipeId;
}
$recipes = Recipes::findBySql(
'SELECT
*
FROM
{{%recipes}}
WHERE
`id` IN ('.implode(', ',array_keys($params)).')
ORDER BY
FIELD (id, '.implode(',', array_reverse(array_keys($params))).')
LIMIT
:limit',
$params + [':limit' => $this->count]
)
->all();
How to solve with ::find() ?
UPD: should be like
$recipes = Recipes::find()
->where(['id' => $recipeIds])
->orderBy(['id' => array_reverse($recipeIds)])
->limit($this->count)
->all();