Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Simple DBI handle caching.

by kyle (Abbot)
on May 11, 2011 at 16:10 UTC ( [id://904196]=note: print w/replies, xml ) Need Help??


in reply to Simple DBI handle caching.

I guess that wasn't so bad.

use English '-no_match_vars'; sub dbh { state $dbh; state $dbh_pid; if ( defined $dbh_pid && $PROCESS_ID != $dbh_pid ) { my $child_dbh = $dbh->clone; $dbh->{InactiveDestroy} = 1; $dbh = $child_dbh; $dbh_pid = $PROCESS_ID; $L->debug( "cloned database connection in PID $dbh_pid" ); } if ( ! defined $dbh ) { my ($u,$p) = ('user',':)'); $dbh = DBI->connect( "dbi:Sybase:server=sql.example.com", $u, $p, { RaiseError => 1 }, ); $dbh->do( $initialization_stuff ); $dbh_pid = $PROCESS_ID; $L->debug( "made new database connection in PID $dbh_pid" ); } return $dbh; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://904196]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-25 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found