From: RQuadling at GMail dot com Operating system: Windows XP SP3 PHP version: 5.3.0alpha2 PHP Bug Type: Reproducible crash Bug description: odbc_next_result corrupts prepared resource
Description: ------------ Using PHP 5.3.0alpha3-dev (cli) (built: Sep 11 2008 09:01:08) Using ODBC to talk to Microsoft SQL Server 7. Using a prepared statement to run a Stored Procedure on the SQL server. Using the function odbc_next_result() to determine if there are more result sets after having retrieved the first result sets kills the prepared statement from re-use and results in an unhandled win32 exception. The SP is not the issue and as a test is the following code: CREATE PROCEDURE dbo.SimpleIdentity @s_Identity AS VARCHAR(500) AS SELECT @s_Identity AS [Simple Identity] GO Removing the odbc_next_result() loop makes everything work. The example code below is from a larger code which deals with getting data from an SP and caching the result(s). Currently I am unable to retrieve multiple result sets AND use stored procedures together. Reproduce code: --------------- <?php // Configure this script. $s_Server = 'BANDVULCSQL'; $s_Database = 'CONTRACTS'; $s_Username = 'sa'; $s_Password = 'sa'; $s_StoredProc = 'SimpleIdentity'; $a_Params = array ( 'Richard', 'Simon', 'John', ); /******************************************/ // Connect to the SQL Server using a DNS-less connection. $r_Connection = odbc_pconnect("Driver={SQL Server};Server={$s_Server};Database={$s_Database}", $s_Username, $s_Password); // Prepare the statement. $r_Statement = odbc_prepare($r_Connection, "EXEC {$s_Database}.dbo.{$s_StoredProc} ?"); // Execute the statement for each parameter. foreach($a_Params as $s_Param) { echo 'About to process : ', $s_Param, PHP_EOL; $b_Executed = odbc_execute($r_Statement, array($s_Param)); do { while(False !== ($a_Row = odbc_fetch_array($r_Statement))) { print_r($a_Row); } } while(True === ($b_MoreResults = odbc_next_result($r_Statement))); } Expected result: ---------------- About to process : Richard Array ( [Simple Identity] => Richard ) About to process : Simon Array ( [Simple Identity] => Simon ) About to process : John Array ( [Simple Identity] => John ) Actual result: -------------- About to process : Richard Array ( [Simple Identity] => Richard ) About to process : Simon and then an unhandled win32 exception in php.cli -- Edit bug report at http://bugs.php.net/?id=46050&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46050&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46050&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46050&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46050&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=46050&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46050&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46050&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46050&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46050&r=support Expected behavior: http://bugs.php.net/fix.php?id=46050&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46050&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46050&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46050&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46050&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46050&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46050&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46050&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46050&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46050&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46050&r=mysqlcfg