Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Mixing Mysql and Perlby paulbort (Hermit) |
on Jan 12, 2004 at 19:53 UTC ( [id://320752]=note: print w/replies, xml ) | Need Help?? |
I've been writing a Perl app (part CGI, part back-end) with lots of SQL mixed in, and our project has pretty much settled into using straight DBI with a hash to contain all the prepared statements, like this:
Then you can easily copy or re-arrange SQL, and just call &closedb when you're finished with db access in the program. It's not OO, it's probably not even a polite way to use global variables (nothing is passed in to &closedb), but it's easy to read, and fast to code, and I like it. If you want to try different SQL, just copy the statement you want to mess with, change the key on one copy to something else (eg, 'DoNotLoseOriginal'), and rock. -- Spring: Forces, Coiled Again!
In Section
Seekers of Perl Wisdom
|
|