adt / bulk-fetcher
Installs: 26 758
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 15
Forks: 0
Open Issues: 0
Requires (Dev)
- kdyby/doctrine: ^3.1
- nette/di: ^2.4 || ~3.0
- nette/utils: ^2.4 || ~3.0
README
\ADT\BulkFetcher\Factory
can be used with:
\Kdyby\Doctrine\ResultSet
\Doctrine\ORM\QueryBuilder
\Kdyby\Doctrine\NativeQueryBuilder
Installation
via composer:
composer require adt/bulk-fetcher
Full example
Whole batch is in transaction.
$qb = $entityManager->createQueryBuilder('user'); try { $entityManager->beginTransaction(); $data = \ADT\BulkFetcher\Factory::create($qb, 100); $data->onBeforeFetch[] = function() use ($entityManager) { $entityManager->commit(); $entityManager->clear(); $entityManager->beginTransaction(); }; foreach ($data as $key => $row) { // code } $entityManager->commit(); } catch (\Exception $e) { $entityManager->rollback(); throw $e; }