adt/bulk-fetcher

v3.0 2019-04-12 12:41 UTC

This package is auto-updated.

Last update: 2020-01-23 14:47:46 UTC


README

\ADT\BulkFetcher\Factory can be used with:

  • \Kdyby\Doctrine\ResultSet
  • \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;
}