CodeIgniter Forums
Multiple databases connection problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Multiple databases connection problem (/thread-58606.html)



Multiple databases connection problem - El Forum - 06-28-2013

[eluser]jahbob[/eluser]
Hi I will try to describe my problem here:

I was running a script locally that handled 3 connections to mysql running at same time with 3 different hosts


Now Im running same script but on one of hosts so I still have 3 connections but 2 of them are from same host, but they are from different databases on same host

The problem is that one of the connections dosnt select the right database, it just selects the last database used for that host .

My configs are :

$config['hostname'] = "host1";
$config['username'] = "x";
$config['password'] = "x";
$config['database'] = "database";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = TRUE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";

$this->conn1= $this->load->database($config,TRUE);



$config2['hostname'] = "host2";
$config2['username'] = "user";
$config2['password'] = "x";
$config2['database'] = "database2";
$config2['dbdriver'] = "mysql";
$config2['dbprefix'] = "";
$config2['pconnect'] = TRUE;
$config2['db_debug'] = TRUE;
$config2['cache_on'] = FALSE;
$config2['cachedir'] = "";
$config2['char_set'] = "utf8";
$config2['dbcollat'] = "utf8_general_ci";

$this->conn2= $this->load->database($config2,TRUE)


$config['hostname'] = "host2";
$config['username'] = "user";
$config['password'] = "x";
$config['database'] = "database3";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = TRUE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";

$this->conn3= $this->load->database($config,TRUE);



The conn2 end up using database3 instead of database2 when I try to query something

So Iam doing something wrong ?



Multiple databases connection problem - El Forum - 06-30-2013

[eluser]jahbob[/eluser]
Anyone ? =\


Multiple databases connection problem - El Forum - 07-01-2013

[eluser]greedyman[/eluser]
[quote author="jahbob" date="1372624668"]Anyone ? =\[/quote]

Did you find your answer on internet? I tried and found a lot.


Multiple databases connection problem - El Forum - 07-01-2013

[eluser]jahbob[/eluser]
Im sorry but I really didnt finded....could u please send me the links that u found ?

Thanks


Multiple databases connection problem - El Forum - 07-02-2013

[eluser]greedyman[/eluser]
[quote author="jahbob" date="1372711296"]Im sorry but I really didnt finded....could u please send me the links that u found ?

Thanks[/quote]

This is for you