Am I correct in this:

Apache::DBI can only really do its stuff when you perform a
DBI->connect, so by calling $dbh = DBI->connect(..) during PerlChildInit
and then never trying to reconnect, you are defeating the purpose of
using Apache::DBI. 

To expand on this, when Apache::DBI intercepts a connection request:
* it returns a stored live handle which matches the connection
credentials
* checks that the handle is indeed still live, and if it isn't,
reconnects automatically (potentially destroying any $sth's that you
have prepared and retained)

So would this be the right balance between efficiency and safety:
1) use Apache::DBI
2) Do "my $dbh = DBI->connect()" at the beginning of each request (ie as
early as required during each request) 
3) use "my $sth = $dbh->prepare_cached()" once as early as required
during each request

This way, we're not expecting the DBI handle to die during a request,
and so avoid calling a few lines of code to ->connect and
->prepare_cached several times during each request.

Have I got the right idea?

thanks

Clint

Reply via email to