Wednesday, 14 December 2016

yii2 where in condition query

In Condition

Sample 1:

1$model = User::find()
2        ->where([
3            'userid' => [1001,1002,1003,1004,1005],
4            ])
5        ->all();

Sample 2:

1$model = User::find()
2        ->where(['IN''userid', [1001,1002,1003,1004,1005]])
3        ->all();    
OUTPUT Query
SELECT * FROM `tbl_user` WHERE `userid` IN (1001, 1002, 1003, 1004, 1005) 

Sample 3:

1$model = User::find()
2        ->where(['NOT IN''userid', [1001,1002,1003,1004,1005]])
3        ->all();    
OUTPUT Query
SELECT * FROM `tbl_user` WHERE `userid` NOT IN (1001, 1002, 1003, 1004, 1005) 

No comments:

Post a Comment