Ask a Question related to PHP Bugs, Design and Development.
-
info at benjamin-wilger dot de #1
#38924 [NEW]: mssql_next_result returns FALSE on multiple Resultsets
From: info at benjamin-wilger dot de
Operating system: Windows
PHP version: 4.4.4
PHP Bug Type: MSSQL related
Bug description: mssql_next_result returns FALSE on multiple Resultsets
Description:
------------
mssql_next_result returns FALSE on multiple Resultsets if a simple select
has been executed and the data is fetched before. If one doesn't run a
query before running a multiple query batch (e.g. Stored Procedure) it
works fine. Look at the reproduce code to completly understand the
problem.
Tested on PHP 4.3.11 (*not* buggy), 4.4.1 (*not* buggy), 4.4.2 (buggy),
4.4.3 (buggy), 4.4.4 (buggy), 5.1.4 (buggy).
Reproduce code:
---------------
<?php
mssql_connect(...); mssql_select_db(...);
$result = mssql_query('SELECT 1');
while($row = mssql_fetch_array($result)) {
$rows_first_query[] = $row;
}
$result = mssql_query('SELECT 1 SELECT 2 SELECT 3'); // Would return three
rows
do {
while($row = mssql_fetch_array($result)) {
$rows_first_query[] = $row;
}
} while ($next_result = mssql_next_result($result)); // Will return FALSE
in any version after 4.4.1 in this case
Expected result:
----------------
On systems with PHP 4.4.1 or lower it will run fine $rows_first_query has
one row
$rows_second_query has *three* rows
Actual result:
--------------
Any version above (including 5.1.x branch) will return just one row in
$rows_second_query.
WORKAROUND to get it running: Run mssql_free_result() after the every
fetching of data.
--
Edit bug report at [url]http://bugs.php.net/?id=38924&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=38924&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=38924&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=38924&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=38924&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=38924&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=38924&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=38924&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=38924&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=38924&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=38924&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=38924&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=38924&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=38924&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=38924&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=38924&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=38924&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=38924&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=38924&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=38924&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=38924&r=mysqlcfg[/url]
info at benjamin-wilger dot de Guest
-
#40234 [NEW]: gethostbynamel always returns false when using PHP as CGI
From: silverbanana at gmx dot de Operating system: Windows XP SP2 PHP version: 6CVS-2007-01-25 (snap) PHP Bug Type: Network... -
#39281 [NEW]: glob() returns false
From: johan dot ekman1 at comhem dot se Operating system: windows xp, apache PHP version: 5.1.6 PHP Bug Type: ... -
[PHP-DEV] [PATCH] substr() returns false
--=-sQWDp5Weadel0FX8XkrW Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, Even though this is documented, it is strange... -
mail() function returns FALSE
Hi All, I'm having trouble getting sendmail to behave with the php mail() function. The function is returning FALSE. Today it doesn't seem to want... -
mail() returns FALSE, no err msg
Sometimes my mail() function returns FALSE, but there is no error message. Error reporting is set to E_ALL. It seems to be a problem of the bcc:... -
fmk@php.net #2
#38924 [Opn->Bgs]: mssql_next_result returns FALSE on multiple Resultsets
ID: 38924
Updated by: [email]fmk@php.net[/email]
Reported By: info at benjamin-wilger dot de
-Status: Open
+Status: Bogus
Bug Type: MSSQL related
Operating System: Windows
PHP Version: 4.4.4
New Comment:
You should always release the result when you are done with it or use a
new variable name for each result if you want to keep multiple results
open.
Two ways to make your code work:
<?php
$con = mssql_connect("localhost", "sa", "s2sihaviv");
$result = mssql_query('SELECT 1', $con);
while($row = mssql_fetch_array($result)) {
$rows_first_query[] = $row;
}
$result2 = mssql_query('SELECT 13; SELECT 2; SELECT 3', $con); // Would
return three rows
do {
while($row = mssql_fetch_array($result2)) {
$rows_first_query[] = $row;
}
} while ($next_result = mssql_next_result($result2)); // Will return
FALSE
print_r($rows_first_query);
?>
<?php
$con = mssql_connect("localhost", "sa", "s2sihaviv");
$result = mssql_query('SELECT 1', $con);
while($row = mssql_fetch_array($result)) {
$rows_first_query[] = $row;
}
mssql_free_result($result);
$result = mssql_query('SELECT 13; SELECT 2; SELECT 3', $con); // Would
return three rows
do {
while($row = mssql_fetch_array($result)) {
$rows_first_query[] = $row;
}
} while ($next_result = mssql_next_result($result)); // Will return
FALSE
print_r($rows_first_query);
?>
Previous Comments:
------------------------------------------------------------------------
[2006-09-22 11:16:53] info at benjamin-wilger dot de
Description:
------------
mssql_next_result returns FALSE on multiple Resultsets if a simple
select has been executed and the data is fetched before. If one doesn't
run a query before running a multiple query batch (e.g. Stored
Procedure) it works fine. Look at the reproduce code to completly
understand the problem.
Tested on PHP 4.3.11 (*not* buggy), 4.4.1 (*not* buggy), 4.4.2 (buggy),
4.4.3 (buggy), 4.4.4 (buggy), 5.1.4 (buggy).
Reproduce code:
---------------
<?php
mssql_connect(...); mssql_select_db(...);
$result = mssql_query('SELECT 1');
while($row = mssql_fetch_array($result)) {
$rows_first_query[] = $row;
}
$result = mssql_query('SELECT 1 SELECT 2 SELECT 3'); // Would return
three rows
do {
while($row = mssql_fetch_array($result)) {
$rows_first_query[] = $row;
}
} while ($next_result = mssql_next_result($result)); // Will return
FALSE in any version after 4.4.1 in this case
Expected result:
----------------
On systems with PHP 4.4.1 or lower it will run fine $rows_first_query
has one row
$rows_second_query has *three* rows
Actual result:
--------------
Any version above (including 5.1.x branch) will return just one row in
$rows_second_query.
WORKAROUND to get it running: Run mssql_free_result() after the every
fetching of data.
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=38924&edit=1[/url]
fmk@php.net Guest



Reply With Quote

