[CDBI] Close CDBI DB connection?

Steven Mackenzie steven.mackenzie at aptile.co.uk
Thu Sep 29 15:51:38 BST 2005



>> Is there a (nice or nasty) way to ask CDBI to disconnect when I'm
>> finished using the database?
yoorobot at gmail.com wrote:
> Class->db_Main->disconnect ?

Yes, thanks, that did the job!

I did search the CPAN doc for "disconnect", and even backing up the doc
hierarchy to Ima::DBI doesn't mention it -- is it a rebellious thing to do?

Stepping through the code I find myself in Ima::DBI and see this:
sub _mk_db_closure {
	my ($class, @connection) = @_;
	my $dbh;
	return sub {
		unless ($dbh && $dbh->FETCH('Active') && $dbh->ping) {
			$dbh = DBI->connect_cached(@connection);
		}
		return $dbh;
	};
}

So I'm getting a random connection from a cache (I guess?), and closing
it. Should I be shutting the cache down instead?

Anyway, thanks, for my current problem you've given me a fine solution,

Steven





More information about the ClassDBI mailing list