connect_cached resets %attr to defaults?
am 23.05.2007 04:04:27 von moseleyDoes connect_cached() reset attributes each time it's called? Even if
just returning an active $dbh?
On a CDBI application I need to access multiple databases with the
same schema. So my initial attempt was:
sub db_Main {
my $self = shift;
my $connection = $database_registry{$current_database};
my %attr = (
$self->_default_attributes,
%{ $connection->{attr} },
AutoCommit => 1,
pg_enable_utf8 => 1,
private_pid => $$,
);
return DBI->connect_cached( @{$connection}{qw/ dsn user pass /}, \%attr );
}
If I localize AutoCommit (for a transaction) I see this:
T <- STORE('AutoCommit' undef)= 1 at test_model.pl line 27
but next time db_Main is called I see:
T <- STORE('AutoCommit' 1)= 1 at DBI.pm line 672
Which looks like attributes are reset when connect_cached is called.
I guess that's why Ima::DBI doesn't call connect_cached() unless ping
fails.
--
Bill Moseley
moseley@hank.org