CodeIgniter Forums
Database Failover in Codeigniter 2.0.2 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database Failover in Codeigniter 2.0.2 (/showthread.php?tid=43745)



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

[eluser]LynxCoder[/eluser]
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..

Cheers


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

[eluser]toopay[/eluser]
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.