tags:

views:

97

answers:

2

I need to build a filter search that returns data using the criteria set. My problem is building the search. It needs to be a OR query because anyone of them could be selected.

http://img200.imageshack.us/img200/2527/screenshot20100118at095.png

This is what will be searched.

Accommodation.space Accommodation.room_type Accommodation.facilities Accommodation.speaks

The only way I can think of doing it is an if statement for each input, but that would be 15 if statements, is there a better way?

+1  A: 

$Model->postConditions($this->data) [reference] can do this for you.

It will auto-generate Cake compatable conditions array, and you can even specify if you want it to be an "AND/OR" operation

duckyflip
A: 

This is a nice component which could likely be tweaked to work for you. It might even work right "out of the box"

http://www.jamesfairhurst.co.uk/posts/view/cakephp_filter_component/

Abba Bryant