I have this wierd problem. I have written a MySQL class that works great, but when I open another connection that uses DIFFERENT connection details, then it is not gonna work.
Example usage:
Code: Select all
$db = new mysql($dbconfig[0]);
$db2 = new mysql($dbconfig[0]);
$db3 = new mysql($dbconfig[0]);
$db4 = new mysql($dbconfig[0]);
$db2 -> query('SELECT name FROM '.PREFIX."settings WHERE id='1';"); // Query Works! :D Code: Select all
$db = new mysql($dbconfig[0]);
$db2 = new mysql($dbconfig[0]);
$db3 = new mysql([color=#BF4040]$dbconfig[1][/color]);
$db4 = new mysql($dbconfig[0]);
$db2 -> query('SELECT name FROM '.PREFIX."settings WHERE id='1';");
// SAME CODE, EXCEPT NUMBER 1 IN $db3'S DEFINITION = DOESNT WORK :(Code: Select all
function mysql($config)
{
$this -> link = @mysql_connect($config['hostname'],$config['username'],$config['password']) or trigger_error(mysql_error());
$this -> select_db = @mysql_select_db($config['database'],$this -> link) or trigger_error(mysql_error());
}Code: Select all
$db = new mysql($dbconfig[0]);
$db2 = new mysql($dbconfig[0]);Code: Select all
$db = new mysql($dbconfig[0]);
$db2 = new mysql($dbconfig[1]); // Config 1 - this will mess up all queries of $db =(So this0:
host:localhost
user:root
pass:
database: triton
1:
host:localhost
user:root
pass:
database:test
Code: Select all
$db = new mysql($dbconfig[0]);
$db2 = new mysql($dbconfig[1]);
$db -> query('SELECT name FROM '.PREFIX."settings WHERE id='1';");Why is it looking at 'test' db instead of 'triton'? Why does that second configuration mess my first configuration?Table 'test.tc_settings' doesn't exist (Line 34.)