Forum Moderators: coopster

Message Too Old, No Replies

Multiple simultaneous database connections

         

benj0323

3:55 am on Oct 25, 2004 (gmt 0)

10+ Year Member



I'm trying to have 2 different links to mysql, so I can work with both connections using mysql_connect($query,$link). Right now I have this:

PHP Code:
var $conn = '';
var $queries = '';

function dbal($mysql_svr,$mysql_usr,$mysql_pw,$mysql_db)
{
$this->conn = mysql_connect($mysql_svr,$mysql_usr,$mysql_pw);
mysql_select_db($mysql_db,$this->conn);
return;
}

function query($query)
{
$result = mysql_query($query,$this->conn);
return $result;
}


When I instantiate this twice into two separate object variables, the second just overwrites the first.

benj0323

1:17 am on Oct 26, 2004 (gmt 0)

10+ Year Member



I solved my own problem. Just for future reference or anyone searching these forums. There is a 4th parameter in the mysql_connection() function. Simply set that to boolean true.

mysql_connect($mysql_svr,$mysql_usr,$mysql_pw,1)

Like that. Settings that to true allows for multiple connections.