[CDBI] Close CDBI DB connection?

yoorobot at gmail.com yoorobot at gmail.com
Thu Sep 29 16:12:56 BST 2005


thats just a standard idiom in DBI... which Ima::DBI and therefore  
Class::DBI inherit from.
db_Main provides access to the db handle.

see the DBI perldoc for more info.

On Sep 29, 2005, at 9:51 AM, Steven Mackenzie wrote:

>
>
>
>>> 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