in reply to Using CGI.pm params to make a DBI MySQL query

I have one comment that hasn't been addressed yet, is slightly OT, but still important.

In your SQL query you may want to explicitly specify the columns you are inserting into. This has a large benefit: if you add a column to the table or the column ordering changes, your code is less likely to break. A good rule of thumb I use is to:

I've found this to be especially helpful in SELECT and INSERT -type statements.

Here's an example that demonstrates what I mean and answers your question:

$dbh->do( 'INSERT INTO table (Col1, Col2, Col3) VALUES (?, ?, ?)', {}, map scalar param($_), qw(Col1 Col2 Col3), );

I began doing this after thinking about the issues raised in Topics in Perl Programming: Table-Mutation Tolerant Database Fetches with DBI, and realizing the way I was doing SQL does not lend itself to change very well.