Larry offers the following suggesting for disconnecting
in CAP::DBH to work well in conjunction with lazy loading.

> From: Larry Leszczynski <[EMAIL PROTECTED]>
> To: Mark Stosberg <[EMAIL PROTECTED]>
> 
> Hi Mark -
> 
> I've been using your C::A::Plugin modules lately - work great, thanks!
> 
> I'm attaching/appending a small patch to C::A::P::DBH that adds a
> "dbh_is_connected" method.  This gets me around a problem in my app where
> I reach the teardown() phase and try to disconnect the database: if it has
> not yet been connected, it gets connected and then immediately
> disconnected.  So this lets me do:
> 
>    $self->dbh->disconnect() if $self->dbh->dbh_is_connected();
> 
> It can be called with or without a handle name.  If that handle has
> previously been connected, it returns a true value (actually, the handle
> name), otherwise it returns 0.

Does anyone have a better idea? One alternative I thought of is to use the hook
system to implement this "maybe disconnect" logic automatically at the end of
the teardown phase.

I think that should work fine with Apache::DBI. Are there cases where you 
/wouldn't/
want the functionality to automatic? 

While Larry's solution is OK, it would seem a shame if it meant that
most people wouldn't use it to implement identical functionality in
teardown when that could be automated.

    Mark


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to