CodeIgniter Forums
Database Failover in Codeigniter 2.0.2 - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter Archived (from EllisLab) (
+--- Forum: Archived Development & Programming (
+--- Thread: Database Failover in Codeigniter 2.0.2 (/thread-43745.html)

Database Failover in Codeigniter 2.0.2 - El Forum - 07-21-2011

Hello All,
Can anyone point me in the right direction? I've got Codeigniter 2.0.2 running on a project that i'm working on, connecting to Xeround Cloud database system, and all is working well. Xeround provide two connection hostnames to provide fall over and i'm looking at how to implement it.

Basically, I want Codeigniter to autoload the database on the primary access (as it does now) and all works fine, but if for some reasons the primary access doesn't work, I need to catch that, and tell it to retry on the secondary. My idea was two have two database groups and if a connection problem occurred, simply swap the active group and retry ... but i'm not sure where and how to check the connection?

Can any one offer any suggestions? I don't really want to have to do a manual database load on all controllers/models etc..


Database Failover in Codeigniter 2.0.2 - El Forum - 07-22-2011

Create MY_Controller.php, put it on "core" folder, and load the database or swap or do anything there. Then simply extend onther controller from it.