以下是我的情况:
'OR' => array( 'AND' => array( array('EventCompetitor.is_black' => 1),array('EventCompetitor.is_adult' => 1) ),'AND' => array( array('EventCompetitor.is_black' => 0),array('EventCompetitor.is_adult' => 0) ),),@H_403_3@当我调试我的查询,它是这样的,这是错误的:
AND ((`EventCompetitor`.`is_black` = 0) AND (`EventCompetitor`.`is_adult` = 0)) AND@H_403_3@现在,这不是我想要的,我想要这样的东西:
((`EventCompetitor`.`is_black` = 1) AND (`EventCompetitor`.`is_adult` = 1)) OR ((`EventCompetitor`.`is_black` = 0) AND (`EventCompetitor`.`is_adult` = 0))@H_403_3@任何想法,我该如何实现? @H_403_3@谢谢 !
您的“OR”键盘数组中的子项名称相同,第二个键有效地覆盖第一个.您需要将这些“AND”条件封装在自己的数组中,以防止密钥冲突.
@H_403_3@例如.代替:
'OR' => array( 'AND' => array( array('EventCompetitor.is_black' => 1),@H_403_3@做:
'OR' => array( array('AND' => array( array('EventCompetitor.is_black' => 1),array('EventCompetitor.is_adult' => 1) )),array('AND' => array( array('EventCompetitor.is_black' => 0),array('EventCompetitor.is_adult' => 0) )),