YII 2におけるandWhere複数orクエリ
993 ワード
複数orの複雑なクエリーを使用するには、次の手順に従います.
AND ((`name`=' ') OR (`name`=' ') OR (`name`=' '))
(https://common.cnblogs.com/images/copycode.gif)](javascript:void(0); "")
// 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']
]
]);