Answer the question
In order to leave comments, you need to log in
How to correctly build a query in yii2 so that one record is taken from each category?
Here is the request:
$query = self::find()->select('id, title, url, img, img_thumb, website_id')->where(['status' => 1])
->andWhere(['in', 'website_id', $array_websites])->limit($sum)->orderBy(new Expression('rand()'))->asArray()->all();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question