I have just been testing an upgrade to codeigniter 2 and have hit a snag. My site uses multiple databases, one being a 'system' database and one of several 'content' databases. Only two databases are loaded at once, the system and whichever content is necessary according to a value in the session.
Because of the use of session, I connect to relevant content database in the constructor of the controllers through a function in MY_Controller.
Somehow, since upgrading to codeigniter 2, the connection object to the content database doesn't make it to the model that would use it.
I.E. the variable of the connection is public'ed at the top of the controllers and model and MY_Controller and MY_Model but by the time it has reached MY_Model, it is no longer an object.
Any ideas what would reset the value of a variable as it is passed to the models in codeigniter 2 but not codeigniter 1.7.3?
Are both databases using same hostname, username, password?
If yes then this is the same problem we just ran into: http://codeigniter.com/forums/viewthread/72240/P15/
We solved it by creating to mysql users with different usernames, userA has access to dbA and userB has access to dbB.
What is happening is when you have:
$this->dbA = $this->load->database('dbA_config', true);
$this->dbB = $this->load->database('dbB_config', true);
When you run line #2 php looks to see if this connection is already open, problem is that php is only looking at the hostname, username, password so when you try to just change database PHP is actually updating dbA by reference.
Hope that helps.
-Noah