in reply to FastCGI DBI connect/disconnect
On the second, assuming that you are actually running under fcgi (which keeps the script running between requests) rather than traditional CGI (in which the script terminates after handling each request), using connect_cached instead of connect is the easiest way to do it.
Alternately, if you really wanted to, you could create $dbh outside of your while (CGI::Fast->new) { ... } loop, so that it never goes out of scope, but then you'd need to watch for whether the database connection has timed out and manually reconnect if it has. connect_cached is generally the better option because it handles that for you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: FastCGI DBI connect/disconnect
by afoken (Chancellor) on Nov 13, 2016 at 10:04 UTC |