Re: Does an explicit database close method exist?

[prev] [thread] [next] [Date index for 2004/09/21]

From: Robert Rombaut
Subject: Re: Does an explicit database close method exist?
Date: 22:04 on 21 Sep 2004
On Sep 20, 2004, at 10:45 AM, Carl Johnstone wrote:

>
>
>> Class::DBI->set_db( 'Main', "dbi:Oracle:$db" );
> [snip]
>> # Return all database handles
>> @dbh = SOME_DBI_CLASS->db_handles;
>>
>> # I only have interest in first because I only have one DB connection.
>> $dbh = $dbh[0];
>>
>> $dbh->disconnect;
>
> If you know you're only ever going to have one DB connection, you 
> should be able to access it through name - which is probably better:
>
>   __PACKAGE__->db_Main->disconnect;
>
> Alternatively loop through all and nuke them from orbit:
>
>   foreach my $dbh (__PACKAGE__->db_handles) {
>     $dbh->disconnect;
>   }
>

Carl,

Yes, I would agree, except that I wrapped a ClassDBI class around 
Class::DBI.  Its sole purpose in life is to provide a default set of 
arguments to Class::DBI->set_db.  From inside our applications we can 
write "ClassDBI->set_db" without arguments or alternatively provide 
named arguments for overriding the defaults; the later will be rare.  
If I ever need to change the default arguments, I only need to change 
ClassDBI::set_db and not all our applications.  Since I could change 
the default "Main" to something else, I didn't want to hardcode 
__PACKAGE__->db_Main->disconnect into the application.  Maybe there's a 
better solution to what I am trying to achieve, but that's where I'm at 
now.

-Bob

RE: Does an explicit database close method exist?
Carl Johnstone 12:14 on 20 Sep 2004

Re: Does an explicit database close method exist?
Robert Rombaut 14:29 on 20 Sep 2004

RE: Does an explicit database close method exist?
Carl Johnstone 14:45 on 20 Sep 2004

Re: Does an explicit database close method exist?
Robert Rombaut 22:04 on 21 Sep 2004

Re: Does an explicit database close method exist?
Perrin Harkins 22:15 on 21 Sep 2004

Generated at 11:35 on 01 Dec 2004 by mariachi v0.52