A useful addition to this might be to stash the returned db handle.
If you're running Apache then then you can do something like the following to share a single connection amongst several scripts:
if (! $Global::var{'dbh'}) { my $sdn = "DBI:mysql:database=$db;host=$host"; my $dbh = DBI->connect($sdn, $user, $pass) || die ("Unable to con +nect to DB: $DBI::errstr"); $Global::var{'dbh'} = $dbh; } return ($Global::var{'dbh'});
In reply to Re: Re: multiple db connects
by jreades
in thread multiple db connects
by jasmine
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |