首页  >  文章  >  php框架  >  YII2中andWhere如何多个or查询

YII2中andWhere如何多个or查询

angryTom
angryTom转载
2019-11-26 17:12:574231浏览

YII2中andWhere如何多个or查询

YII2中andWhere如何多个or查询

使用多个or的复杂查询:

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']
    ]
]);

推荐:《YII教程》  

以上是YII2中andWhere如何多个or查询的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:cnblogs.com。如有侵权,请联系admin@php.cn删除