multiple db error |
[eluser]aligator[/eluser]
Hello, I want to use 2 databases in a codeigniter project. i read the documentation for configuring the app to recognize both db: http://ellislab.com/codeigniter/user-gui...cting.html This is my config/database.php file: Code: /* Principals Database */ In my first controller, the main one i need to use the default db. I understood that i don't have to declare the db i want to use, the "default" group one will be used. is this correct? In another controller, after i passed the first one(which does a login logic) i want to use another db, the second one. so in my model (where i extract data) i load the second db: Code: $DB2 = $this->load->database('second_db', TRUE); Code: $query = $this->$DB2->get('tablename');.. An then when i want to try everything, so start with the login and so on i get this error: "An Error Was Encountered You have specified an invalid database connection group." now i am confused i checked to see if i wrote the group wrong for the second db but i didn't. i tried even to place on "TRUE" in database.php for the second db, and no better result. I left it on FALSE thinking that this way the 2 db are not considered active on the same time, and i choose when the second one is active. does this make sense to you? Did u had this problem? i know is from my code, i can't figure out from where. Thank you for your time. :red:
[eluser]aligator[/eluser]
i changed Code: $group = "second_db"; So by this i should understand that all new databases should be declared like this(at the begining)?
[eluser]techgnome[/eluser]
Oi! There's a couple things wrong with that.... First, the name of the second group of db configuration needs a different name. By using "default" you just over wrote the settings for the default group. Second.... the Active_Group setting should point to the group you want to use as your DEFAULT database connection. Code: /* Principals Database */ For the record, I have three in mine - 1 default and 2 alternates - as long as you give them different names for hte group, you have have as many as you want. -tg
|
Welcome Guest, Not a member yet? Register Sign In |