Suppose that I have an enum column on a table and I want users to be able to expand the number of values it contains via an HTML form submission on the front end by using PHP to run a query that alters the table to contain more enum values for that column .
- Is it a bad idea to run queries very
often that will alter the a table
structure? - Is there a security issue
inherent that I can’t see? - If I sanitize user input before
altering the table with the new
values is that sufficient?
As Col.Shrapnel already said, yes, it’s a bad idea. Unless you’re making an application specifically meant to admin a database, it’s generally bad practice to allow your app to alter a database in any way with very few exceptions (so feel free to use temp tables). Doubly so in PHP. The most immediately apparent impact is if you modify any enum list value, this field in all records in the table using that old value will be erased. A choice quote from mysql manual…