首頁 >php框架 >YII >YII2中andWhere如何多個or查詢

YII2中andWhere如何多個or查詢

angryTom
angryTom轉載
2019-11-26 17:12:574278瀏覽

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刪除