Home >PHP Framework >YII >How to query multiple or in andWhere in YII2
How to query multiple ors in andWhere in YII2
Complex query using multiple ors:
AND ((`name`='张三') OR (`name`='李四') OR (`name`='王五'))
// AND ((`name`='张三') OR (`name`='李四') OR (`name`='王五')) $query->andWhere(['or', ['name' => '张三'], ['name' => '李四'], ['name' => '王五'] ]);
AND (((name=‘张三’) AND (phone=‘15200000000’)) OR ((name=‘李四’) AND (phone=‘15300000000’)))
// AND (((`name`='张三') AND (`phone`='15200000000')) OR ((`name`='李四') AND (`phone`='15300000000'))) $query->andWhere(['or', ['and', ['name' => '张三'], ['phone' => '15200000000'] ], ['and', ['name' => '李四'], ['phone' => '15300000000'] ] ]);
Recommended: " YII Tutorial》
The above is the detailed content of How to query multiple or in andWhere in YII2. For more information, please follow other related articles on the PHP Chinese website!