Bug #54444 [NEW]: Multiple Queries on a single conenction

From: Date: Fri, 01 Apr 2011 14:13:50 +0000
Subject: Bug #54444 [NEW]: Multiple Queries on a single conenction
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-159895@lists.php.net to get a copy of this message
From:             
Operating system: Ubuntu 10 64 bit
PHP version:      5.3SVN-2011-04-01 (SVN)
Package:          MySQLi related
Bug Type:         Bug
Bug description:Multiple Queries on a single conenction

Description:
------------
Hi, trying to build a generic DB object handler for mySqli, and have hit an
issue where we can't have more than one open query on the same connection.
Is this a bug or 'expected behaviour'?
Looking at the mysqli.c source code, it looks like it should have been
possible, but it looks like the second object overwrites the first...

I have put a sample snippet below of what I am trying to achieve.... if
this helps.

Any help greatly appreciated....

OS: 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:09:38 UTC 2010 x86_64
GNU/Linux
PHP Version => 5.3.2-1ubuntu4.5

	


Test script:
---------------
-------------- Code Snippet -----------------------------
$sqlstock = 'select foo1 from bar1 where foo1 =?';
$sqltime  = 'select foo2, foo3 from bar2 where foo4 =?';

$varinp = "XXXXXXXXXXXX";
$abindVars = array(0=>$varinp);
	
$varProd = '';
$conn = dbi->db_conn;
$sprod = '';
$timestart = microtime_float();
	
// Get a statement
$aRes = array();
$aRes2 = array();

// Init 2 Statements	
$stmt  = mysqli_stmt_init($conn);
$stmt2  = mysqli_stmt_init($conn);
	
// Prepare 2 statements
mysqli_stmt_prepare($stmt,$sqlstock);
mysqli_stmt_prepare($stmt2,$sqltime);
	
// Set the bind variable
$varinp = "PXX00019263";
	
// Bind the statements	
mysqli_stmt_bind_param($stmt,'s', &$varinp);
mysqli_stmt_bind_param($stmt2,'s', &$varinp);
	
// Execute - Second one fails	
mysqli_stmt_execute($stmt);
mysqli_stmt_execute($stmt2);
	
// Set up field Defs
$aFieldDefs = array();
$aFieldDefs2 = array();
	
// Get result Metadata
$result = mysqli_stmt_result_metadata($stmt);
$result2 = mysqli_stmt_result_metadata($stmt2);
	

$nCount = 0;
while($aFieldDefs[$nCount] = mysqli_fetch_field($result)){
        echo('Field = '.print_r($aFieldDefs, true)."\r\n");
	$aRes[$aFieldDefs[$nCount++]->name] = null;
}

$nCount = 0;
while($aFieldDefs2[$nCount] = mysqli_fetch_field($result2)){
	echo('Field = '.print_r($aFieldDefs2, true)."\r\n");
	$aRes2[$aFieldDefs2[$nCount++]->name] = null;
}
	
// Bind Results
mysqli_stmt_bind_result($stmt, &$aRes['foo1']);
mysqli_stmt_bind_result($stmt2, &$aRes2['foo2'], &$aRes2['foo3'])
// Fetch Results
mysqli_stmt_fetch($stmt);
mysqli_stmt_fetch($stmt2);
	
echo(print_r($aRes, true)."\r\n");
echo(print_r($aRes2, true)."\r\n");
--------------- End Code Snippet ----------------------

Expected result:
----------------
Array
(
    [foo1] => 'PXX00019263'
)

Array
(
    [foo2] => 2009-09-15 12:05:02
    [foo3] => 0000-00-00 00:00:00
)


Actual result:
--------------
Array
(
    [foo1] => 
)

Array
(
    [foo2] => 2009-09-15 12:05:02
    [foo3] => 0000-00-00 00:00:00
)


-- 
Edit bug report at http://bugs.php.net/bug.php?id=54444&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=54444&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=54444&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=54444&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=54444&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54444&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=54444&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=54444&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=54444&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=54444&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=54444&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=54444&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=54444&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=54444&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=54444&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54444&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54444&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=54444&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=54444&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=54444&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=54444&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=54444&r=mysqlcfg



Thread (8 messages)

« previous php.bugs (#159895) next »