in reply to Re: check if DBI is still connected
in thread check if DBI is still connected
because most posts about this say to simplymy $dbh = "123456"; # just as a test, instead of DBI->connect(....); if ($dbh != valid_DBI_handle()) { print "please supply a PROPER reference to a DBI object, or whatever + it's called\n"; } else { # okay, dbh actually points to a real db connection print "dbh is truly valid"; }
well, if $dbh eq 1, then we try to run_some_command will fail, and cause a bad user experience, to the point where the user's trust in the site dies along with the script!if (!$dbh) { die "no db connection!"; } else { $dbh->run_some_command(); }
|
|---|