Re: Apache::DBI
[prev]
[thread]
[next]
[Date index for 2005/01/08]
--=-ovb6mjLkRRoJfi3EellK
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Hi Angie,
> I'm hoping to have a persistent database connection for each request,
> but not get values mixed up between requests and sites.
I think you should be able to connect to your datasource and store the
connection in Apache pnotes something like this in your main connection
routine:
my $dbh;
if ( $ENV{'MOD_PERL'} and !$Apache::ServerStarting ) {
$dbh =3D Apache->request()->pnotes('dbh');
}
if ( !$dbh ) {
$dbh =3D DBI->connect_cached(
$config->get_dsn(), $config->get_user(),
$config->get_password(), $db_options
);
if ( $ENV{'MOD_PERL'} and !$Apache::ServerStarting ) {
Apache->request()->pnotes( 'dbh', $dbh );
}
}
return $dbh;
> I thought I'd ask the experts here before I go do something really
> bloated.
I am a bit new to the list and mod_perl, but I have asked the same
question behind the scenes and received help from the list, you will
probably here from others more qualified with a more elegant problem
solution ;)
I use the above code with Apache 1.33 and its corresponding mod_perl.
HTH,
CPF
--=-ovb6mjLkRRoJfi3EellK
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQBB4DbC+9mRKowXEYARArPFAKCCoe3kt01ty+AsLPHHr4gZFXZ5iwCgqhc8
59awvknvxVesTyY1nCQa6aQ=
=14es
-----END PGP SIGNATURE-----
--=-ovb6mjLkRRoJfi3EellK--
 |
(message missing)
|