Anthony Amolochitis - 2015-09-18 15:53:36
I notice that many people submit PHP classes that dynamically generate SQL. I even wrote a class that generates SQL, but the code is not dynamic, it is static. Code is generated by a predefined database with tables in it already. My reasoning is that if you already "know" the database, and it's tables' structures, then you should not waste looping cycles trying to create/recreate the same SQL repeatedly. Typically, your database and tables structure should already be known. I understand a field, table may be added, but the class that represents them can easily be changed in one location... At the site of the class that represents it.
So, my reason for posting this is to get some opinions, and facts, on the following questions.
Why we should dynamically generate SQL on a table that is static?
Isn't is inefficient to continuously run a loop on a SQL statement for a table that does not change?
When should we dynamically generate SQL?