Wednesday, January 16, 2013

Advanced find with mulitple OR/WHERE/AND conditions

Hi all.. I am looking to do a search for ITEMS with mulitple conditions.

1 = location_start
2= location_end
3=start_date
4=end_date

Here is what I have this far:

$start_date = date("Y-m-d 00:00");
$end_date = date("Y-m-d 23:59");

$conditions = array(
                'Item.published' => 1,
                    "OR" => array(
                        array('Item.start_date BETWEEN ? AND ?' => array($start_date,$end_date)),
                        array('Item.end_date BETWEEN ? AND ?' => array($start_date,$end_date)),
                        array('FIND_IN_SET(\''. $this->request->data['Search']['location_from'] .'\',Item.location_start)'),
                        array('FIND_IN_SET(\''. $this->request->data['Search']['location_to'] .'\',Item.location_end)')
                    )
                );


I can not seem to get the selection according to the dates going.
Finding the items that have set dates between start_date and end_date.

Item.start_date & Item.end_date are stored in db like this: Y-m-d H:i

Any suggestions????

-Tom

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: