How to implement automatic reconnection in PDO?
| From: | Christian Hammers | Date: | Sun, 26 Jul 2009 21:38:12 +0000 |
| Subject: | How to implement automatic reconnection in PDO? | ||
| Groups: | php.pdo | ||
| Request: | Send a blank email to pdo+get-219@lists.php.net to get a copy of this message | ||
Hello
Any ideas how to implement automatic reconnection in an PDO application?
I want to distinguish between a connection error, after which the
program would sleep 10s and then try a reconnect (at most 3 times)
and everything else like syntax errors which are final.
Just repeat every command three times would stall the program for e.g.
30s every time an error occurs. This is of course very annoying and
only acceptable in cases where it could really help.
With MySQL I would have checked for SQLSTATE[HY000] or the MySQL
specific code 2002 "Can't connect..."
bye,
-christian-