From: warden at warden dot cz Operating system: Gentoo Linux PHP version: 4.4.4 PHP Bug Type: MySQL related Bug description: Can't make 2 instances of mysql class, each has to connect another server
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 bug report at http://bugs.php.net/?id=38563&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38563&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38563&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38563&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38563&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38563&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38563&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38563&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38563&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38563&r=support Expected behavior: http://bugs.php.net/fix.php?id=38563&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38563&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38563&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38563&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38563&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38563&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38563&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38563&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38563&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38563&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38563&r=mysqlcfg