0

I am writing from the ground up a feature for this one company in Georgia while I am in school. It is running on mysql, but I have encountered a problem (actually a few problems, which led to this problem). I use auto increment for the unique identifiers for each of my tables. Now when I insert into a table, all the examples of inserts tell me to type out all of my column names. This would not bother me so much if I could use stored procedures (my boss does not feel they are enterprise ready yet, and I would have to say that I agree with him). Since I cannot use stored procedures, I am writing the scripts in php in an include file and have php query the database, not a stored procedure. In terms of securing the data model (which I would have to say I am very proud of), this is not a good idea. Should anyone get a hold of the php code, they could easily figure out my entire data model, just not the primary keys.

Is there a way to insert into a table while skipping over a particular column without having to type out all the column names? For instance:

Insert into table1 values (id, info1, info2, info3); /* indiscriminate insert */
Insert into table1 (column2, column3, column4) values (info1, info2, info3); /* insert I have now */
Insert into table1 (all but column1) values (info1, info2, info3); /* insert I want */

Any help would be appreciated.

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by Troy
0

I've looked into this "issue" myself a few times. First, I've been doing this long enough to vouch that you really do want to specificy exact columns. I only use '*' in my quick & dirty test code.

To my knowledge there is not any way to do exactly what you describe.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.