Answer the question
In order to leave comments, you need to log in
Is it possible in yii2?
How to insert values from an array instead of $ids so that the query works? I tried everything already spent 6 hours on it.
$ids = [1,2,3,4,5,6];
$query->select('product.id, product.name, product_id,
COUNT(CASE WHEN product_ingredient.ingredient_id IN ('.$ids.')
THEN 1 END) AS ing_count');
Answer the question
In order to leave comments, you need to log in
$ids = [1,2,3,4,5,6];
$query->select('product.id, product.name, product_id,
COUNT(CASE WHEN product_ingredient.ingredient_id IN ('.implode(",", $ids).')
THEN 1 END) AS ing_count');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question