[Dbix-class] db handle disconnect?
Tim Keefer
tkeefer at gmail.com
Wed Aug 9 18:12:16 CEST 2006
unfortunately I didn't make note of the versions before I upgraded.
We're trying to accomplish two things,
1) pull database connection info out of our conf so the models can be shared
between the web apps, scripts, etc.
2) avoid extraneous connects to the database.
Here's the exact code reference:
sub db_Main {
my $invocant = shift;
my $class = ( ref $invocant ) ? ref $invocant : $invocant;
my $dbh;
my $helper = Gantry::Utils::DBConnHelper->get_subclass();
$dbh = $helper->get_dbh();
if ( not $dbh ) {
my $conn_info = $helper->get_conn_info();
my $db_options = $class->get_db_options();
$db_options->{AutoCommit} = 0
unless defined $db_options->{AutoCommit};
$dbh = DBI->connect_cached(
$conn_info->{ 'dbconn' },
$conn_info->{ 'dbuser' },
$conn_info->{ 'dbpass' },
$db_options
);
$helper->set_dbh( $dbh );
}
return $dbh;
} # end db_Main
On 8/9/06, Brandon Black <blblack at gmail.com> wrote:
>
>
>
> On 8/9/06, Tim Keefer <tkeefer at gmail.com> wrote:
> >
> > Anyone have some insight as to why I'm unable to successfully cache the
> > dbh?
> >
> > When calling the connect method I pass it a code reference like so:
> >
> > my $dbh = get_dbh();
> > if ( ! $dbh ) {
> > $dbh = DBI->connect_cached ....
> > store_dbh( $dbh );
> > }
> > return $dbh;
> >
> > This used to work with the older version of DBIx::Class.
> >
> > Thanks,
> > Tim
> >
>
>
> I'm not sure why you're usage broke. Could you be more explicit? What
> version did it work in? What version broke you? What's the exact subref
> you're passing to connect, and what else does it interact with (what does
> the code for get_dbh and store_dbh do, exactly)?
>
> Aside from all of that, what are you really trying to accomplish? The
> coderef form of input to connect_info was designed for certain very unusual
> usages that can't be handled any other (saner) way.
>
> -- Brandon
>
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
> http://www.mail-archive.com/[email protected]/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060809/24657d9c/attachment-0001.htm
More information about the Dbix-class
mailing list