Cakephp - detect if unable to connect to database and recover gracefully
- by Phantz
I have a few sites built with Cakephp. If any of these sites lose their connection to the database for whatever reason it does not handle it well. Basically it renders itself inside itself trying to display an error over and over until the browser crashes. The rendering itself inside itself is caused by the use of requestAction from elements.
What I want to know is how can I check if the database connection exists
I tried this in the app_controller before filter:
if(!ConnectionManager::getDataSource('default'))
{
die(); //this will be a message instead
}
but it does not seem to work.
Thanks