Best way to implement search? |
[eluser]Craig A Rodway[/eluser]
I do a similar thing in a website I'm currently working on, except it's the search parameters that are stored and not the exact results for a given query - but it could be easily modified to do that. Once the search form is submitted and validated as normal, I run the serialize() function over the posted form data. I then store this in a database table with an auto-increment primary key field. I get the ID, and redirect to a /search/results/$id page. The ID is looked up in the database, unserialize() is ran to get the original form data into an array, and the database search is then carried out using this data and results displayed. When my underlying data changes, the results for a given search will also be up to date. If it is definitely the result data you want to be the same, regardless if it has since changed, then it might be best to look into a cache library, such as MP_Cache to store the results. Essentially you would run the query, get the results, and then check if the results are in the cache using a generated hash (md5 or sha1). If the results aren't in the cache, store them; otherwise retrieve them from the cache to show. |
Messages In This Thread |
Best way to implement search? - by El Forum - 01-02-2010, 10:58 PM
Best way to implement search? - by El Forum - 01-03-2010, 06:35 AM
Best way to implement search? - by El Forum - 01-03-2010, 01:19 PM
|