note 43984 deleted from function.sqlite-fetch-single by cmb
| From: | cmb@php.net | Date: | Mon, 02 Nov 2020 14:59:56 +0000 |
| Subject: | note 43984 deleted from function.sqlite-fetch-single by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215735@lists.php.net to get a copy of this message | ||
Note Submitter: roga at yoopee dot de
----
Be careful with the use of sqlite_fetch_single() in a while-loop:
<?php
$result = sqlite_query($db_handle, 'SELECT foo FROM bar;');
while ($row = sqlite_fetch_single($result)) {
/*...do s.th. with $row...*/
}
?>
This may not work as expected because the loop will stop if any of the foos has a false value (e.g.
zero).
Use sqlite_has_more() instead:
<?php
$result = sqlite_query($db_handle, 'SELECT foo FROM bar;');
while (sqlite_has_more($result)) {
$row = sqlite_fetch_single($result);
/*...do s.th. with $row...*/
}
?>