CodeIgniter Forums
Using Hooks to select Database - 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: Using Hooks to select Database (/showthread.php?tid=5604)



Using Hooks to select Database - El Forum - 01-28-2008

[eluser]faceh[/eluser]
I am creating a code base where many different domain names will point to the same codeigniter installation, each having their own SQL database.

I want to use Hooks (or any other appropriate method) to select which SQL Database to use. My first thought is to use a pre_controller hook to grab the domain name using $_SERVER[http_host], and then use this to determine which client it is. The problem is passing this information from the hook to the database file, as the db file only uses local variables.

Any thoughts?


Using Hooks to select Database - El Forum - 01-28-2008

[eluser]sophistry[/eluser]
is this new Events contribution of any use?

http://ellislab.com/forums/viewthread/69753/


Using Hooks to select Database - El Forum - 01-28-2008

[eluser]faceh[/eluser]
looks pretty interesting, but on further messing around i managed to avoid Hooks altogether. Instead I'm loading the database library manually and grabbing the settings on the fly. Lot nicer than hacking the core, etc.

Thanks for your help anyway, I might use it in the future.