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 = Apache->request()->pnotes('dbh');
  }
  if ( !$dbh ) {
      $dbh = 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

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to