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

[prev] [thread] [next] [Date index for 2004/07/29]

From: jason scott gessner
Subject: Re: ASP setup using common set of C::DBI modules
Date: 20:24 on 29 Jul 2004
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?



-jason scott gessner
     jason@xxxxxxxx.xxx

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

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