There's more than one way to do things | |
PerlMonks |
(dkubb) Re: (1) Using CGI.pm params to make a DBI MySQL queryby dkubb (Deacon) |
on Oct 10, 2001 at 06:57 UTC ( [id://117919]=note: print w/replies, xml ) | Need Help?? |
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:
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.
In Section
Seekers of Perl Wisdom
|
|