Jay B Sat Jul 31 09:42:37 -0400 2010

Subject: Handling failover - detecting non-working connections?


I wonder what's a good approach on checking if the current DB connection is available or not, and how to handle that gracefully - not throwing the default PHP error in other words.


Also interesting: Can I try to one database connection and if it fails, try another?

Kien La Thu Aug 05 21:06:31 -0400 2010

Can't say whether checking for failed connections is good or bad. I'd probably lean towards bad.

Assuming you do want to you want to re-connect after detecting a failed connection you can do so by calling SomeModel::reestablish_connection()

Jay B Mon Aug 16 13:09:04 -0400 2010

Hi Kien,

Thanks for your involvement and support!

We need a way to check whether we could establish connections to the database, which we could implement in our testing function that verifies that our app is connected to our mySQL database, noSQL database and memcached cluster.
Too get the default exception being thrown by PHP will not be sufficient, so is there any good workaround for this besides modifying the connection part in the activeRecord core?

Thanks a lot!