I need to save user searches in the database so that the user could see the results against those searches anytime he wants and also he can get email notifications if any new record matches their search criteria.In short, i want something like the saved search thing in http://www.immobilienscout24.de/
Here in http://www.immobilienscout24.de/ i can search properties giving different search params and can save that search.Then i have a "Saved searches" option that lists down all the saved searches with "show" option.Clicking on the "show" option displays the results against that saved search.
I thought of two solutions which are as follows:-
- Take all the search params and make a query using them.Store that query in database.I am preferring this solution till now as it only requires fetching and executing the query when one wants to see the results against a specific search.The only disadvantage i think in this is the chances of sql injection but it can somehow be managed as i will be making query myself and will check for sql injections
- Store the search param as a json object.When viewing the results against the saved search,this will require to first fetch that json object,decode it and making a query out of it and executing it.
I want to know if there are some better solutions to save the user searches in database.Also what are the disadvantages of the above mentioned solutions.What problems i might be facing using one of the above solutions?