#35993 [NEW]: mysql_query doesnt honor database resource id
From: andreas at fink dot org
Operating system: MacOS X & Linux
PHP version: 5.1.2
PHP Bug Type: MySQL related
Bug description: mysql_query doesnt honor database resource id
Description:
------------
When you use multiple connections to mysql databases, you should use a
resource id in your query which you got back at the time of connection.
However this doesnt work anymore. The queries always go to one database.
Reproduce code:
---------------
mysqladmin create test1
mysqladmin create test2
mysql << --EOF--
use test1
CREATE TABLE \testdata\ (\id\ int(20) NOT NULL
auto_increment,\data\
varchar(255) NOT NULL default '', PRIMARY KEY (\id\) ) ENGINE=MyISAM
DEFAULT CHARSET=latin1;
grant all on test1.* to 'test'@'localhost' identified by 'test';
insert into test1.testdata(id,data) values (1,'This is DB named test1');
use test2
CREATE TABLE \testdata\ (\id\ int(20) NOT NULL
auto_increment,\data\
varchar(255) NOT NULL default '', PRIMARY KEY (\id\) ) ENGINE=MyISAM
DEFAULT CHARSET=latin1;
grant all on test2.* to 'test'@'localhost' identified by 'test';
insert into test2.testdata(id,data) values (1,'This is DB named test2');
--EOF--
now launch php on this:
<?
$db1_handle=mysql_pconnect("127.0.0.1","test","test");
mysql_select_db("test1",$db1_handle);
$db2_handle=mysql_pconnect("127.0.0.1","test","test");
mysql_select_db("test2",$db2_handle);
$query = "select data from testdata where id=1";
$result1 = mysql_query($query,$db1_handle);
$line = mysql_fetch_row ( $result1 );
echo "This query was executed on db1_handle:" .$line[0] ."\n";
$query = "select data from testdata where id=1";
$result2 = mysql_query($query,$db2_handle);
$line = mysql_fetch_row ( $result2 );
echo "This query was executed on db2_handle:" .$line[0] ."\n";
?>
Expected result:
----------------
This query was executed on db1_handle:This is DB named test1
This query was executed on db2_handle:This is DB named test2
Actual result:
--------------
On Linux i386:
This query was executed on db1_handle:This is DB named test2
This query was executed on db2_handle:This is DB named test2
On MacOS X PPC:
This query was executed on db1_handle:This is DB named test1
This query was executed on db2_handle:This is DB named test1
Interesting enough that i386 and ppc are exactly reversed. This might hint
to a location which is endian sensitive.
--
Edit bug report at http://bugs.php.net/?id=35993&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35993&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35993&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35993&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35993&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35993&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35993&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35993&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35993&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35993&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35993&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35993&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35993&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35993&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35993&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35993&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35993&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35993&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35993&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35993&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35993&r=mysqlcfg
Thread (13 messages)
- andreas at fink dot org
- andreas at fink dot org#35993 [Opn]: mysql_query doesnt honor database resource id
- tony2001@php.net#35993 [Opn->Bgs]: mysql_query doesnt honor database resource id
- andreas at fink dot org#35993 [Bgs->Opn]: mysql_query doesnt honor database resource id
- tony2001@php.net#35993 [Opn->Bgs]: mysql_query doesnt honor database resource id
- andreas at fink dot org#35993 [Bgs->Opn]: mysql_query doesnt honor database resource id
- tony2001@php.net#35993 [Opn->Bgs]: mysql_query doesnt honor database resource id
- andreas at fink dot org#35993 [Bgs->Opn]: mysql_query doesnt honor database resource id
- georg@php.net#35993 [Opn->Bgs]: mysql_query doesnt honor database resource id
- andreas at fink dot org#35993 [Bgs->Opn]: mysql_query doesnt honor database resource id
- sniper@php.net#35993 [Opn->Fbk]: mysql_query doesnt honor database resource id
- andreas at fink dot org#35993 [Fbk->Opn]: mysql_query doesnt honor database resource id
- sniper@php.net#35993 [Opn->Bgs]: mysql_query doesnt honor database resource id