I needed to "peek" at the next record in order to
see if fetching it would go too far. So I want to do a
fetch, followed by seek(-1).
I could find no function to move the internal row pointer
relative to it's current position, or to retrieve it as a
row number as required by mysql_data_seek(). This limits
the function's usefulness to resetting the row to 0, unless
you track the row number yourself.
If you use a While loop to step through the results, you can
increment a tracking index at the bottom of the loop. But
be sure never to use Continue; which would bypass your
index. And document this restriction for the person who
needs to maintain your code. It's probably better to use a
For loop, which makes the index explicit.
In either case be sure to range check the index when you
manipulate it. E.G. When I "peek" at the next
record I must check for index>=count (end of data). Or
if I decrement the index, make sure it does not go negative.
Again, document why you are coding it this way, so the next
programmer doesn't "correct" the inelegant code.
----
Server IP: 208.69.120.35
Probable Submitter: 24.131.35.146
----
Manual Page -- http://www.php.net/manual/en/function.mysql-data-seek.p
hp
Edit -- https://master
.php.net/note/edit/76050
Del: integrated -- h
ttps://master.php.net/note/delete/76050/integrated
Del: useless -- http
s://master.php.net/note/delete/76050/useless
Del: bad code -- htt
ps://master.php.net/note/delete/76050/bad+code
Del: spam -- https:/
/master.php.net/note/delete/76050/spam
Del: non-english --
https://master.php.net/note/delete/76050/non-english
Del: in docs -- http
s://master.php.net/note/delete/76050/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/76050
Reject -- https://mast
er.php.net/note/reject/76050
Search -- https://
master.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|