note 25367 added to function.odbc-fetch-row

From: Date: Fri, 20 Sep 2002 17:42:00 +0000
Subject: note 25367 added to function.odbc-fetch-row
Groups: php.notes 
Request: Send a blank email to php-notes+get-37061@lists.php.net to get a copy of this message
The odbc_fetch_row() function worked fine when I used PHP version 4.0.6 but when I upgraded PHP to 4.2.2, the odbc_fetch_row() doesn't work when there is 1 row. When I use the echo command to see the response to the odbc_fetch_row() before the while loop, it showed that it doesn't return True or anything when there is 1 row. I made the workaround to the problem by including the "$bug_workaround" into the script, this is to be use as 'row number' as shown in the PHP manual at "http://www.php.net/manual/en/function.odbc-fetch-row.php". I enclosed two clipping to point this out. The 1st clipping is the one that don't work and the 2nd clipping showed the work-around to it. In this script, you'll find the word, 'INQUIRIES', it is a table that contain number of companies and users. What the script does is to display each user whenever the company is selected. The cool thing about it is it won't display the data if there is no row for any user. --clip-- $cid = odbc_connect('blah blah blah'); $ask7 = "SELECT * FROM INQUIRIES WHERE USER_ID = '38SCK3'"; $R7 = odbc_exec($cid,$ask7); $result = odbc_result($R7,1); echo "Result or No Result??? --> ".odbc_fetch_row($R7); while (odbc_fetch_row($R7)) { odbc_fetch_into($R7,$inquiry,$inq_c); echo $inquiry[0], $inquiry[1]; } --clip-- --clip-- $cid = odbc_connect('blah blah blah'); $ask7 = "SELECT * FROM INQUIRIES WHERE USER_ID = '38SCK3'"; $R7 = odbc_exec($cid,$ask7); $result = odbc_result($R7,1); echo "Result or No Result??? --> ".odbc_fetch_row($R7); $bug_workaround=0; while (odbc_fetch_row($R7,++$bug_workaround)) { odbc_fetch_into($R7,$inquiry,$inq_c); echo $inquiry[0], $inquiry[1]; } --clip-- I post this into bugs.php.net as well. See bug #19528 -- http://www.php.net/manual/en/function.odbc-fetch-row.php http://master.php.net/manage/user-notes.php?action=edit+25367 http://master.php.net/manage/user-notes.php?action=delete+25367 http://master.php.net/manage/user-notes.php?action=reject+25367

« previous php.notes (#37061) next »