Would just like to point out for clarification that each call to fetchArray() returns the next result from SQLite3Result in an array, until there are no more results, whereupon the next fetchArray() call will return false.
HOWEVER an additional call of fetchArray() at this point will reset back to the beginning of the result set and once again return the first result. This does not seem to explicitly documented, and caused me my own fair share of headaches for a while until I figured it out.
For example:
<?php
$returned_set = $database->query("select query or whatever");
while($result = $returned_set->fetchArray()) {
$returned_set->fetchArray();
}
?>
Basically, in the above code fetchArray will return:
1st call | 1st result from $returned_set (fetchArray() call from while condition)
2nd call | 2nd result (fetchArray() call from while block)
3rd call | 3rd result (fetchArray() call from while condition)
4th call |FALSE (fetchArray() call from while block)
5th call | 1st result (fetchArray() call from while condition)
....
This will cause (at least in this case) the while loop to run infinitely.