I am working an a search page that allows users to search for houses for sale. Typical search criteria include price/zip code/# bedrooms/etc.
I would like to allow the user to save this criteria in a database and email new homes daily.
I could either:
1) Serialize a "SavedSearch" object into a string and save that to the database, then deserialize as needed.
2) Have a list of columns in a tblSavedSearch corresponding to the search criteria - price/zip/# bedrooms/etc.
I am concerned that if I choose option 1, my saved search criteria will change and leave the searialized objects in the database invalid, but option 2 doesn't feel like an optimal solution either.
How have others solved this problem?
The purpose of every database is to store information, texts, images, even media files. All dynamic modern websites rely on one or more databases for storing articles and other published content, information about the users, contact information, connections to other websites, ads, etc.
To save a search: Enter the search in the search box. Click the Create Alert link under the search box.
I assume you will need to re-run the search daily in order to find new additions to the results. Maybe it is possible to make sure that you search form specifies a get method so that the search criteria is appended to the url as a query string then save the entire querystring in the database.
So if you have a search program called search.action you will request the search like this:
search.action?price=20000&rooms=3
You can save the price=20000&rooms=3 part into the database. To retrieve this search simply append the query string onto the url and request the seach page again.
The only caveat is as the search action changes you have to make intelligent defaults to avoid breaking old searches. For example, suppose you start searching by color, none of the old searches will have a color criteria so your search action will have to cater for this and make sure that something reasonable like ALL colors is used instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With