I’m using codeigniter and the project i’m working on has to be in two languages.
The only thing i can’t figure out is how to select a different database in codeigniter when a session variable is set to a certain value.
example:
if the session variable ‘language’ is set to ‘EN’ i want it to select the DB:
“databasename_EN”
in all other cases select DB:
“databasename_EN”
The only thing i found was that you can do $this->db->load(‘bla’); but this means you have to add a DB-load in every model and you have to disable autoload ‘database’.
For the best result I would create a pre_system hook that checks whether a $_SESSION[‘lang’] variable exists and if it does set a constant:
Then in your database config file do this:
Should do the trick with minimum fuss.