Hi all,

I'm using DBI to connect to a mySQL DB.  I want to make two connections at
the same time, as seen here:

$DBI{database} = "DBI:mysql:db_a";
$DBI{hostname} = A hostname;
$DBI{username} = A Username;
$DBI{password} = A Password;

$DBI{db} = join (":",$DBI{database},$DBI{hostname});
$db_driver = DBI->install_driver("mysql",$DBI{'username'},$DBI{'password'});
$db_master = DBI->connect($DBI{'db'},$DBI{'username'},$DBI{'password'}, {
RaiseError => 1}) || die $DBI::errstr;

$DBI{forum_db} = "db_b";
$db_forums = DBI->connect($DBI{'db'},$DBI{'username'},$DBI{'password'}, {
RaiseError => 1}) || die $DBI::errstr;
$db_forums->do( "use $DBI{forum_db}" );

Basically, $db_forums can be any number of different db's depending upon
certain veriables, but to get a persistant connection, I'm connecting to the
server and then "use"ing the correct DB.

The problem that I have is that the system works fine under normal uses.

However, when I run it under mod_perl and Apache_DBI, the
$db_forums->do{"use $DBI{forum_db}" );  also changes the $db_master
reference as well.

So my question is, am I doing something wrong here?

$db_master will always point to one database, but $db_forums will point to
different ones.  I can "use" a the correct db before each reference to it,
but that seems like an awful lot of useless calls.

I can't figure out why changing $db_forums would affect $db_master.

Any clues are much appreciated.

Mark W

Reply via email to