ID: 46050
Updated by: [EMAIL PROTECTED]
Reported By: RQuadling at GMail dot com
Status: Open
-Bug Type: Reproducible crash
+Bug Type: ODBC related
Operating System: Windows XP SP3
PHP Version: 5.3.0alpha2
New Comment:
Reclassified in correct category. And you should use PDO ODBC instead
anyway.
Previous Comments:
------------------------------------------------------------------------
[2008-09-11 13:33:33] RQuadling at GMail dot com
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 this bug report at http://bugs.php.net/?id=46050&edit=1