I'm not sure whether these are programming questions, but I'm sure lots of new programmer like myself has been asking the same questions.
I've created a webservice to update data to a vfp free tables using php.I use VfpOledb to connect php and the tables. Many client use this webservice to update their data to several tables in the server. Example : user A update to table t_sales in directory X, user B update to table t_sales in directory Y, user C update to table t_sales in directory Z.
The questions are :
which one is better/faster and why : creating a different php files (webservice) for a different user, or creating one php file with a switch case part inside to determine the datasource location?
which one is better/safer and why : send the datasource location as a parameter from the user, or store the datasource location in the php file?
Many thanks
By datasource location, I will assume you are referring to the DB server and table. Assuming the DB server and table is yours, and you want to restrict which tables users have access to, you should determine the db info internally.
Web services should provide an API that are accessed like "/myservice/update?name=x&email=y&key=32453457830957834", with only the required bits of information being:
This makes it easy to use your web service, and makes it secure against injection attacks as long as you escape the input. (If you allow the table to be defined as a parameter, you can't escape it, and then you, and your users, are at the users' mercy.)
As for performance, the logic of deciding how to access the DB is negligible for most applications, compared to the time it takes for a DB transaction.