[cgiapp] Lazy DBI

Perrin Harkins perrin at elem.com
Tue Feb 19 11:36:57 EST 2008


On Feb 19, 2008 5:02 AM, Mark Knoop <mark at rawcane.net> wrote:
> I would be interested to know of any flaws in my logic...

This is okay for CGI.  It would not be good for any persistent
environment like FastCGI, PerlEx, or mod_perl.  It those environments
it will break if your database connection times out from inactivity or
if you restart your database server (it won't reconnect on the next
request).

If you get rid of the "our $dbh" and call connect_cached() instead of
connect(), it will accomplish the same thing, but also work without
changes when you switch to a persistent environment.

- Perrin


More information about the cgiapp mailing list