Nodemon
Nodemon

Reputation: 1046

andfilterwhere for multiple selection in yii2

How can i customize the below query for multiple select status filter in a array using Yii2

Query: SELECT FROM STATUS WHERE ID IN (1, 2, 3, 4);

I need to convert above code like below FilterWhere format

Code:

$query->andFilterWhere([
            'status' => $this->status
        ]);

I need to filter for multiple status.

Upvotes: 1

Views: 1257

Answers (2)

sarin surendran
sarin surendran

Reputation: 303

This will help you ...

 $query->andFilterWhere([ 'in','status',$this->status]);

Upvotes: 1

Bharat Chauhan
Bharat Chauhan

Reputation: 3332

try this:

$query->where(['id' => [1,2,3,4]]);

Upvotes: 0

Related Questions