Re: ASP setup using common set of C::DBI modules

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

From: Tim Bunce
Subject: Re: ASP setup using common set of C::DBI modules
Date: 19:06 on 01 Aug 2004
On Thu, Jul 29, 2004 at 03:24:34PM -0500, jason scott gessner wrote:
> Hi All.
> 
> I tried this out and it kinda works.
> 
> Basically, it workds if i do this at the top of each of my autohandlers:
> my $dbh = PS::DBI::dbh();
> 
> Otherwise, db_Main() is being cached somewhere and never going out of 
> scope, leading to some requests going to another vhost's database.  
> This is a real bummer.  Any thoughts?

Adding the vhost name to the connect_cached() attribute hash would
ensure each vhost gets separate connections. A dummy private attribute
would work for that:

	private_vhost_name => $vhost_name

Tim.

> On Jul 28, 2004, at 3:48 PM, Tony Bowden wrote:
> 
> >On Wed, Jul 28, 2004 at 04:33:38PM -0400, Michael Graham wrote:
> >>The code looks something like this:
> >>    package My::Class::DBI::Base;
> >>    use base 'Class::DBI';
> >>    use CLASS;
> >>    use My::Config;
> >>    use DBI;
> >>
> >>    sub db_Main {
> >>        my ($dsn, $user, $pass) = 
> >>My::Config->get_config('dbi_connection_info');
> >>        my %attr = CLASS->_default_attributes();
> >>        my $dbh = DBI->connect_cached($dsn, $user, $pass, \%attr);
> >>
> >>        return $dbh;
> >>    }
> >
> >One slight problem with this is your use of CLASS. This means that
> >subclasses can't provide their own default attributes.
> >
> >You'd be better off here with:
> >
> >     sub db_Main {
> >         my $class = shift;
> >         my ($dsn, $user, $pass) = 
> >My::Config->get_config('dbi_connection_info');
> >         my %attr = $class->_default_attributes();
> >         return DBI->connect_cached($dsn, $user, $pass, \%attr);
> >     }
> >
> >Tony
> >
> 

ASP setup using common set of C::DBI modules
jason scott gessner 19:43 on 28 Jul 2004

Re: ASP setup using common set of C::DBI modules
Michael Graham 20:33 on 28 Jul 2004

Re: ASP setup using common set of C::DBI modules
Michael Graham 22:01 on 28 Jul 2004

Re: ASP setup using common set of C::DBI modules
jason scott gessner 20:24 on 29 Jul 2004

Re: ASP setup using common set of C::DBI modules
Tim Bunce 19:06 on 01 Aug 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52