1. Go to this page and download the library: Download awesomite/iterators library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
awesomite / iterators example snippets
function getAllFromDatabase($tableName)
{
$page = 0;
$perPage = 1000;
while ($rows = Db::getRows($tableName, $page, $perPage)) {
foreach ($rows as $row) {
yield $row;
}
$page++;
}
}
use Awesomite\Iterators\CallbackIterator;
function getAllFromDatabase($tableName)
{
$page = 0;
$perPage = 1000;
$rows = [];
return new CallbackIterator(function () use (&$rows, $tableName, &$page, $perPage) {
if (!$rows) {
$rows = Db::getRows($tableName, $page, $perPage);
$page++;
}
if ($rows) {
return array_shift($rows);
}
CallbackIterator::stopIterate();
});
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.