Re: query conditions problem - OR is always replaced by AND
I usually wrap in sub-arrays. 'conditions' => array( array('AlbumsUser.album_id' => 'AlbumsUser2.album_id'), 'OR' => array( array('AlbumsUser2.user_id' => null), array('AlbumsUser2.user_id' => 1) ), ), On Sep 1, 8:10 am, "Mariano C." wrote: > this works, not yours, don't ask me why O_o > > 'OR' => array > ( > 'AlbumsUser2.user_id' => null, > 'OR' => array('AlbumsUser2.user_id' => 1) > ), > > On 1 Set, 12:40, red wrote: > > > The part with or should be: > > 'OR' => array( > > 'AlbumsUser2.user_id' => null, > > 'AlbumsUser2.user_id' => 1 > > ) > > > On 1 Wrz, 11:36, "Mariano C." wrote: > > > > I have to write a simple query something like: > > > > SELECT ... FROM ... > > > LEFT JOIN ... > > > ON (`AlbumsUser`.`album_id` = 'AlbumsUser2.album_id' AND > > > ((`AlbumsUser2`.`user_id` IS NULL) OR (`AlbumsUser2`.`user_id` = > > > 1))) > > > ... > > > > this is conditions array I've write: > > > > 'conditions' => array > > > ( > > > array('AlbumsUser.album_id' => > > > 'AlbumsUser2.album_id'), > > > array( > > > 'AlbumsUser2.user_id' => null, > > > 'OR' => > > > array('AlbumsUser2.user_id' => 1) > > > ), > > > ), > > > > and this is the sql that I get: > > > > ON (`AlbumsUser`.`album_id` = 'AlbumsUser2.album_id' AND > > > ((`AlbumsUser2`.`user_id` IS NULL) AND (`AlbumsUser2`.`user_id` = > > > 1))) > > > > How can I get the proper OR? Where I wrong? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: query conditions problem - OR is always replaced by AND
this works, not yours, don't ask me why O_o 'OR' => array ( 'AlbumsUser2.user_id' => null, 'OR' => array('AlbumsUser2.user_id' => 1) ), On 1 Set, 12:40, red wrote: > The part with or should be: > 'OR' => array( > 'AlbumsUser2.user_id' => null, > 'AlbumsUser2.user_id' => 1 > ) > > On 1 Wrz, 11:36, "Mariano C." wrote: > > > > > I have to write a simple query something like: > > > SELECT ... FROM ... > > LEFT JOIN ... > > ON (`AlbumsUser`.`album_id` = 'AlbumsUser2.album_id' AND > > ((`AlbumsUser2`.`user_id` IS NULL) OR (`AlbumsUser2`.`user_id` = > > 1))) > > ... > > > this is conditions array I've write: > > > 'conditions' => array > > ( > > array('AlbumsUser.album_id' => > > 'AlbumsUser2.album_id'), > > array( > > 'AlbumsUser2.user_id' => null, > > 'OR' => array('AlbumsUser2.user_id' > > => 1) > > ), > > ), > > > and this is the sql that I get: > > > ON (`AlbumsUser`.`album_id` = 'AlbumsUser2.album_id' AND > > ((`AlbumsUser2`.`user_id` IS NULL) AND (`AlbumsUser2`.`user_id` = > > 1))) > > > How can I get the proper OR? Where I wrong? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: query conditions problem - OR is always replaced by AND
The part with or should be: 'OR' => array( 'AlbumsUser2.user_id' => null, 'AlbumsUser2.user_id' => 1 ) On 1 Wrz, 11:36, "Mariano C." wrote: > I have to write a simple query something like: > > SELECT ... FROM ... > LEFT JOIN ... > ON (`AlbumsUser`.`album_id` = 'AlbumsUser2.album_id' AND > ((`AlbumsUser2`.`user_id` IS NULL) OR (`AlbumsUser2`.`user_id` = > 1))) > ... > > this is conditions array I've write: > > 'conditions' => array > ( > array('AlbumsUser.album_id' => > 'AlbumsUser2.album_id'), > array( > 'AlbumsUser2.user_id' => null, > 'OR' => array('AlbumsUser2.user_id' > => 1) > ), > ), > > and this is the sql that I get: > > ON (`AlbumsUser`.`album_id` = 'AlbumsUser2.album_id' AND > ((`AlbumsUser2`.`user_id` IS NULL) AND (`AlbumsUser2`.`user_id` = > 1))) > > How can I get the proper OR? Where I wrong? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en