On Wed, Jan 7, 2009 at 5:12 PM, Rob Wilkerson <r...@robwilkerson.org> wrote: > On Wed, Jan 7, 2009 at 4:50 PM, gearvOsh <mileswjohn...@gmail.com> wrote: >> >> Here you go: >> >> return $this->find ( >> 'list', >> array ( >> 'fields' => array ( 'Alert.message' ), >> 'conditions' => array ( >> 'Alert.alert_subject_id' => strtoupper ( $subject ), >> 'OR' => array( >> array( >> 'Alert.start_date' => null, >> 'Alert.start_date <= ' => date ( 'Y-m-d >> H:i:s' ) >> ), >> array ( >> 'Alert.end_date' => null, >> 'Alert.end_date >= ' => date ( 'Y-m-d H:i:s' ) >> ) >> ) >> ) >> ) >> ); > > I really appreciate the help, but that's not quite right. That syntax > ANDs the two start_date values and ANDs the two end_date values, but > ORs the two condition pairs. I need to do exactly the opposite: > (start_date condition1 OR start_date condition2) AND (end_date > condition1 OR end_date condition2).
Aaaah. Having finally realized that I was defining two 'OR' keys in the same array, I tried it by creating an array out of each or and it worked. The syntax doesn't read very well to me as a newbie, but it does make sense: return $this->find ( 'list', array ( 'fields' => array ( 'Alert.message' ), 'conditions' => array ( 'Alert.alert_subject_id' => strtoupper ( $subject ), array ( 'OR' => array ( 'Alert.start_date' => null, 'Alert.start_date <= ' => date ( 'Y-m-d H:i:s' ) ) ), array ( 'OR' => array ( 'Alert.end_date >= ' => date ( 'Y-m-d H:i:s' ) , 'Alert.end_date' => null ) ) ) ) ); -- Rob Wilkerson http://robwilkerson.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---