Search by field only when set |
[eluser]Andy UK[/eluser]
Hi guys, I'm looking for a way to refine the results of a search by adding search criteria and running it again. Basically i want to do something like this but with activerecords: http://stackoverflow.com/questions/11460...h-criteria For example, my initial search returns a list of properties based on city, price and number of bedrooms. I would now like to filter by those results to show properties in a specific neighbourhood with 2 parking spaces. Here is a snippet of my current code that returns the initial result Code: $q = $this->db->select("*") What i want is a way to add criteria to the initial search query so that it can run for both the initial search and for subsequent searches to filter the results. One possible solution would be if i could write a query that involves some kind of wildcard (*) like here: Code: // Set default values if session variables are empty as is the case with the initial search Whilst with the parking spaces i can simply set a very high default value, with the neighbourhood i need to select one in particular or show all of them if no filter has been set. However, as you probably already know, the above does not work. Can anyone help point me in the right direction? |
Welcome Guest, Not a member yet? Register Sign In |