Welcome Guest, Not a member yet? Register   Sign In
multiple database & autoload: trouble!
#1

[eluser]Fabdrol[/eluser]
Hi folks!

I'm upgrading a website for a client I built a while ago.. The upgrade includes a new version of the content management system, but the client's asked me to wait upgrading the content area's of the site, except for the 'events' area. Now I've run across a problem...

The original site connects to the database by autoloading the library, and all models use the database via $this->db. Now i've got one controller, Events.php, using another database (database_2) for it's main funcion, and using database_1 for some small widgets...

Since I've got to upgrade the rest of the site in a while, it isn't worth it to change all controllers and models right now, so I need a way to keep using database_1 as I was, without changing any of the code, and still using database_2 AND database_1 next to each other in the Events controller.

The things I tried...

In __construct in the controller:
Code:
$this->db2 = $this->load->database('database_2', true);

but that gave an error that the tables used in the models (for the widgets) couldn't be found in the database_2 database. But those models should use database_1..

Next I tried to assing database_2 to an variable encapsuled inside the function that actually called to the database_2 db, but that didn't work either.

Anybody ever crossed this problem? I really, really need to find a solution for this...

thanks in advance!
Fabian




Theme © iAndrew 2016 - Forum software by © MyBB