Welcome Guest, Not a member yet? Register   Sign In
how to load multiple databases/models
#1

[eluser]face1m[/eluser]
Greetings Forum: I was trying to load multiple database using the method described in the manual.
$var = $this->db->load->database('hot_lotto', [True/False]);
$var2 = $this->db->load->database('cashg', [True/False]);

I set up the database.php file like so:

$db['hot_lotto']['hostname'] = "localhost";
...

$db['cashg']['hostname'] = "localhost";
...

With this configuration, I can only access one database, the last one defined. I loaded the db's in the controller file. Tried using both true/false options without success. The database class is loaded in autoload.php.

$active_group = "hot_lotto";
$active_record = TRUE;

I am using the lastest CI version. what am i doing wrong? thanks in advance.
rick
#2

[eluser]theprodigy[/eluser]
in your database.php config file, try setting the pconnect values to false.
#3

[eluser]face1m[/eluser]
OK. Tried that and still no help. I double checked my setting with the examples in the manual. It will load one database, but not two. I'm stuck!
rick
#4

[eluser]danmontgomery[/eluser]
Take DB out of autoload. You're trying to load two separate database objects into the database object created by autoload. You should be doing this in the controller, not the database object.

Code:
$var = $this->load->database('hot_lotto');
$var2 = $this->load->database('cashg');




Theme © iAndrew 2016 - Forum software by © MyBB