Re: Apache::DBI

[prev] [thread] [next] [Date index for 2005/01/08]

From: Charles P. Frank
Subject: Re: Apache::DBI
Date: 19:38 on 08 Jan 2005
--=-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)

Apache::DBI
Angie Ahl 19:07 on 08 Jan 2005

Re: Apache::DBI
Charles P. Frank 19:38 on 08 Jan 2005

Re: Apache::DBI
Perrin Harkins 19:49 on 08 Jan 2005

Re: Apache::DBI
Martin Moss 16:06 on 09 Jan 2005

Apache::DBI
Ian Joyce 04:01 on 30 Jan 2005

Re: Apache::DBI
Perrin Harkins 04:25 on 30 Jan 2005

Re: Apache::DBI
Ian Joyce 05:17 on 30 Jan 2005

Re: Apache::DBI
Perrin Harkins 18:18 on 30 Jan 2005

Generated at 12:39 on 05 Feb 2005 by mariachi v0.52