From: Josh Danziger <[EMAIL PROTECTED]>
>
>Many bargain basement
web hosts will have SQL connections automatically die with an extremely
short timeout period.  If this is the case, then the connection might die in
between one execution and the next.  Therefore, it is important to check
that the database is alive before actually using it.  For example, using the
$dbh->ping() method.

I never liked the approach of pinging the DBH *before every* access. Since the 
occasional error is the exception, why not write a small common "retry" routine 
that would only be called if the access fails? If it fails, drop the presumably 
prepared statement handle, prepare again. If it fails, drop the DBH and all 
prepared statement handles, reconnect, prepare the statement handle. 

This eliminates a needless ping before what should be a predominance of 
successful accesses. The post-access error test has to be there anyway. All you 
need is something slightly elaborate to decide how to handle the error (whether 
to undef/re-prepare the statement, undef/re-connect to the database).

I guess it has to do with how obsessed a person might be with performance. But, 
once you write the error handler it works for any application.

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