Welcome Guest, Not a member yet? Register   Sign In
How to resolv mutil database connect which is diffenet db type?
#8

[eluser]Unknown[/eluser]
Hello,

i'm probably late in my answer, but it may help someone else.

I use in a website an odbc connection to one database and about 20 mysql databases.

What I did is to make my default connection to the odbc one i need, and in a model i set "dynamicly" the others connections i use (I use at least 3 connections at the same time) like this :

function bdd($bd)
{
$config['hostname'] = "My hostname";
$config['username'] = "my user";
$config['password'] = "my pass";
$config['database'] = $bd;
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = TRUE;
$config['db_debug'] = TRUE;
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
return $this->load->database($config, TRUE);
}

In any of my other function i call it like this :

$db1 = $this->bdd('database1');
$res = $db1->query($query);

$db2 = $this->bdd('database2');
$res2 = $db2->query($query2);

And to use the default database, i use $this->db->query....

Sorry for my poor english and hope it helps.


CodeIgniter 1.6.3 (works with 1.5.4 too)


Messages In This Thread
How to resolv mutil database connect which is diffenet db type? - by El Forum - 07-11-2008, 03:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB