One such way involves the ability to move the
row ???pointer??? around the result set. Several functions are offered for doing just this,
all of which are introduced in this section.
Retrieving the Row Residing at the Current Pointer Position
The sqlite_current() function is identical to sqlite_fetch_array() in every way
except that it does not advance the pointer to the next row of the result set. Instead,
it only returns the row residing at the current pointer position. If the pointer already
resides at the end of the result set, FALSE is returned. Its prototype follows:
array sqlite_current(resource result [, int result_type [, bool decode_binary]])
CHAPTER 22 ?– SQLITE 583
Determining Whether the End of a Result Set Has Been Reached
The sqlite_has_more() function determines whether the end of the result set has
been reached, returning TRUE if additional rows are still available, and FALSE otherwise.
Its prototype follows:
boolean sqlite_has_more(resource result_set)
An example follows:
$sqldb = sqlite_open("mydatabase.db");
$results = sqlite_query($sqldb, "SELECT * FROM employee");
while ($row = sqlite_fetch_array($results,SQLITE_BOTH)) {
echo "Name: $row[1] (Employee ID: ".$row['empid'].")
";
if (sqlite_has_more($results)) echo "Still more rows to go!
";
else echo "No more rows!
";
}
sqlite_close($sqldb);
?>
This returns the following:
Name: Jason Gilmore (Employee ID: 1)
Still more rows to go!
Name: Sam Spade (Employee ID: 2)
Still more rows to go!
Name: Ray Fox (Employee ID: 3)
No more rows!
Moving the Result Set Pointer Forward
The sqlite_next() function moves the result set pointer to the next position, returning
TRUE on success and FALSE if the pointer already resides at the end of the result set.
Pages:
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668