Yii2 - WHERE IN with active record

ID : 274511

viewed : 48

Tags : yii2yii2





Top 2 Answer for Yii2 - WHERE IN with active record

vote vote

95

As documentation about where() says:

['id' => [1, 2, 3], 'status' => 2] generates (id IN (1, 2, 3)) AND (status = 2)

so your method should be correct. If you want to use IN then your code should look like this:

public function static findProductsOnSale($ids) {     return $this->find()->where(['in', 'product_id', $ids])->count(); } 
vote vote

84

Top 3 video Explaining Yii2 - WHERE IN with active record







Related QUESTION?