I’m building an Online Food Ordering System with PHP and MYSQL, One of the feature of the application is to allow users to search for the restaurants by typing the area name.
I would like to know using PHP for search will be more efficient or using Stored Procedure or using any third party tool.
Efficient in the sense when it is to be searched among large set of data which one will be the fastest?
Most likely this should be done with SQL. This would be simpler and have better performance.
But would depend on a few details. Especially how exact or complicated you want it to be able to find the information the user typed in (maybe a list of available areas would be a better ui option here)
You could do a simple search like:
SELECT * FROM areas WHERE name LIKE 'input%';
This would of course fail for any typo the user makes and maybe return several records and you would have to offer the user further options to select one of those.
Assuming at some point you found a single record, it should be simple to find restaurants by area_id.
2
You may need to redesign how client provide “area” information. The geography information is naturally in hierarchy. So you’d better provide a multi-steps input process. All restaurants are stored with state,city,town or street information, client will be provided with drop-down list, first select a state, then select a city, then a town or street, then you fetch the corresponding restaurants and display them on the page.
Or, leverage map service provider’s API, first convert their INPUT into coordinates. And you have coordinates information associated with each restaurant.
1