php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17305 Handle multiple connection in SQL Server
Submitted: 2002-05-18 08:16 UTC Modified: 2002-05-24 06:57 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: vania at fe dot up dot pt Assigned:
Status: Closed Package: PEAR related
PHP Version: 4.2.0 OS: Win 2000
Private report: No CVE-ID: None
 [2002-05-18 08:16 UTC] vania at fe dot up dot pt
It seems that DB.php cannot handle different connections for SQL Server. I noticed that you fixed this for MySQL. 

In mysql.php you have this:
 if ($dsninfo['database']) {
            // fix to allow calls to different databases in 
            the same script
            if (empty($GLOBALS['_DB_mysql_changed_database'])) {
                $this->_changed_db = false;
                if (!@mysql_select_db($dsninfo['database'], $conn)) {
                    return $this->raiseError(DB_ERROR_NODBSELECTED, null, null, null, mysql_error($conn));
                }
            } else {
                $GLOBALS['_DB_mysql_changed_database'] = true;
                $this->_changed_db = $dsninfo['database'];
            }
        }

And in mssql.php it's only this:

        if ($dsninfo['database']) {
            if (!@mssql_select_db($dsninfo['database'], $conn)) {
                return $this->raiseError(DB_ERROR_NODBSELECTED, null, null, null, mssql_get_last_message());
            }
        }


In my scripts I noticed that it handles only the last connection made and ignores queries with the other objects created to access database.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-24 05:10 UTC] alex at netflex dot nl
Hi,

i am running w2k php 4.2 too.


$conn1 = mysql_connect("localhost", "user", "pass");

$conn2 = mysql_connect("localhost", "user", "pass");

mysql_select_db("test1" , $conn1);

mysql_select_db("test2" , $conn2); // it sets the db for $conn1 and $conn2!!! NOT only for $conn2

$sql = "SELECT * FROM test";

$result1 = mysql_query($sql, $conn1);

$result2 = mysql_query($sql, $conn2); 


$result1 is the same as $result2!!!!!!!!!
 [2002-05-24 06:57 UTC] cox@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 12:01:30 2024 UTC