开发者

Taking wrong database configuration array

I have one application in which i have used 2 database connections. In my database config file i have given two arrays as below.

$active_group = ‘default’; $active_record = TRUE;

FIRST ARRAY $db[‘default’][‘hostname’] = ‘hostname’; .............. ..........

SECOND ARRAY $db[‘another_db’][‘hostname’] = ‘hostname’; .............. ..........

this is working fine.

Now, I copied the entire CI folder to develop another application in which only one database connection needed.

So, now, in the database config file, i deleted the second configuration array. But, the db class is taking first application’s second array i.e. “another_db” and it is giving the below error.

“You have specified an invalid database connection group.”

When i change the default (only one) array name to “another_db” in configuration file. It is working fine. Can’t understand from where it is taking the group name as “another_db”.

My application autoloads database library. I have debugged the ci_auto_loader in Loader.php class where it calls $this->database() function with no parameters. But in function database($params, $, $) {}, if I echo $params it shows开发者_如何学Python “another_db”.


To select the first database just do: $this->load->database();

and queries: $this->db->get('table');

to Select the second_db: $DB2=$this->load->database(‘another_db’);

$DB2->get('Table');

Regards,
Pedro


There's a line in the main config file for the database that sets which connection to use. Just change that name to the new one and that should fix your problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜