ID: 38563 User updated by: warden at warden dot cz Reported By: warden at warden dot cz -Status: Bogus +Status: Open Bug Type: MySQL related Operating System: Gentoo Linux PHP Version: 4.4.4 New Comment:
I tried, but nothing happend... Previous Comments: ------------------------------------------------------------------------ [2006-08-23 13:24:37] [EMAIL PROTECTED] Use 4th parameter of mysql_connect(). ------------------------------------------------------------------------ [2006-08-23 13:18:23] warden at warden dot cz Description: ------------ I have a mysql class. When I create an instance, constructor makes connection to server. Then I can use methods to do something with this connection. If I make 2 instances in the same script and each instance is created to connect to another server, the second connection resource rewrites resource in first class. Reproduce code: --------------- PART OF USING: $this->sql = new c_mySqlEx("first", "frs_svr", "login", "pass"); $this->secondSql = new c_mySqlEx("second", "sec_svr", "login", "pass"); $server_select = $this->sql->dbQuery("db", "query"); $server_record = $this->sql->fetchArray($server_select); PART OF CLASS: class c_mySql { var $identify; var $server; var $login; var $pass; var $connection; /* cons */ function c_mySql($conIdentify = "", $conServer = "", $conLogin = "", $conPass = ""){ $this->identify = $conIdentify; $this->server = $conServer; $this->login = $conLogin; $this->pass = $conPass; $this->connect(); } /* connect */ function connect(){ $this->connection = mysql_connect($this->server, $this->login, $this->pass); if (!$this->connection){ echo "error..."; } } function dbQuery($db, $query){ $mysqlDBQuery = MySQL_DB_Query($db, $query); if (!$mysqlDBQuery){ echo "error..."; } else { return $mysqlDBQuery; } } function fetchArray($result, $errMode = 1){ @$mysqlFetchArray = MySQL_Fetch_Array($result); if ((!$mysqlFetchArray) && ($errMode == 1)){ echo "error..."; } else { return $mysqlFetchArray; } } ........ Expected result: ---------------- Each instance can work with mysql on the expected (another) server. Actual result: -------------- The second connect resource (in the second resource) rewrites resource in the first instance. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38563&edit=1