PHP code example of wiistriker / doctrine-cursor-iterator
1. Go to this page and download the library: Download wiistriker/doctrine-cursor-iterator 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/ */
wiistriker / doctrine-cursor-iterator example snippets
$cursorPaginator = new DoctrineORMCursorPaginator($qb);
foreach ($cursorPaginator->batch() as $entities) {
foreach ($entities as $testEntity) {
$cnt++;
}
}
$myBatchSize = 1000;
$cursorPaginator = new DoctrineORMCursorPaginator($qb);
foreach ($cursorPaginator->batch($myBatchSize) as $entities) {
}
foreach ($cursorPaginator->batch() as $entities) {
foreach ($entities as $entity) {
// ... process the entity
}
$entityManager->clear(); // detach processed entities and free memory
}
$cursorPaginator = new DoctrineORMCursorPaginator($qb, AbstractQuery::HYDRATE_ARRAY);