#27557 [Opn->Fbk]: DB2 odbc_fetch_row with single row returns invalid result
| From: | sniper@php.net | Date: | Thu, 11 Mar 2004 14:19:19 +0000 |
| Subject: | #27557 [Opn->Fbk]: DB2 odbc_fetch_row with single row returns invalid result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-56305@lists.php.net to get a copy of this message | ||
ID: 27557
Updated by: sniper@php.net
Reported By: admin at db-hq dot net
-Status: Open
+Status: Feedback
Bug Type: ODBC related
Operating System: Linux - Fedora Core 1
PHP Version: 4.3.4
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2004-03-10 19:16:38] admin at db-hq dot net
Description:
------------
I am working on porting phpbb over to DB2, and ran into an error with
odbc_fetch_row. When the following SQL is executed:
SELECT * FROM phpbb_fourms WHERE forum_id = 1
odbc_fetch_row($result_id, $i) returns false. Where i = 1.
Sending the query to the database returns one row. When I remove the $i
from odbc_fetch_row it works perfectly. Also if more than one result is
returned there is no problem. Also it seems to only occur when there is
a select * or when there is a large number of columns returning a
single row.
I am pretty sure I have experienced this bug since the early 4.0.*
days.
Reproduce code:
---------------
$i = 1;
$k = 0;
while(odbc_fetch_row($result_id, $i) && $k <
$this->result_numrows[$result_id]){
for($j = 1; $j < count($this->result_field_names[$result_id])+1;
$j++){
$this->result_rowset[$result_id][$k][$this->result_field_names[$result_id][$j-1]]
= odbc_result($result_id, $j);
}
$i++;
$k++;
}
Expected result:
----------------
Expected odbc_fetch_row($result_id, $i) to return true.
Actual result:
--------------
odbc_fetch_row($result_id, $i) returned false if just one row was
selected from the database. If more than one row was selected it
returned true and worked fine.
Removing the $i from odbc_fetch_row() fixed the problem. None the less
it is still appears a bug. I also verified that the database query does
return one result.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27557&edit=1