The Scenario
I have an iOS app where I am POSTing data to a web service. Each time, the POST data has a different amount of variables, and is meant to be sent to a specific table in a database, which has that same amount of variables. I have 37 tables, and they range in size from 3 to 27 columns (and the POST statements range in size from 3 to 27 variables).
The Question
I was going to use prepared statements, until I found that you can not change the table name (or row name) in prepared statements. So is there anyway I can avoid using 37 if/else statements? Or will that be the only way to direct the data to the appropriate table?
Identifying your table by the number of columns is a very bad idea, what if you have 2 tables with the same number of columns?
My suggestion is to add a flag on your URL when posting to your server ex:
and so on. of course you will not use the exact table name in the url that will be a security breach.