The point of failure for my website is the database. I connect to it in a line included on all pages on the site that looks like this:
$GLOBALS['database'] = new PDO('mysql:mysql.host.address;dbname=db1', 'USER', 'PASSWORD');
If the database has too many connections open, I get a fatal error. I'd like to do this:
header('Location: http://www.website.org/sorry.php', true, 302);
Is there a test that will, instead of giving a "too many errors" message, let me do that 302? Do I need to use a timer that's one second less than the timeout on mysql?