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

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

From: Tony Bowden
Subject: Re: ASP setup using common set of C::DBI modules
Date: 20:48 on 28 Jul 2004
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
Tony Bowden 20:48 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