Download the PHP package ocramius/doctrine-batch-utils without Composer
On this page you can find all versions of the php package ocramius/doctrine-batch-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ocramius/doctrine-batch-utils
More information about ocramius/doctrine-batch-utils
Files in ocramius/doctrine-batch-utils
Package doctrine-batch-utils
Short Description A set of utilities to operate with Doctrine ORM's batch processing functionality
License MIT
Homepage https://github.com/Ocramius/DoctrineBatchUtils
Informations about the package doctrine-batch-utils
DoctrineBatchUtils
This repository attempts to ease the pain of dealing with batch-processing in the context of Doctrine ORM transactions.
This repository is maintained by Patrick Reimers (PReimers).
Installation
Supported installation method is via Composer:
Current features
As it stands, the only implemented utility in this repository is an
IteratorAggregate
that
wraps around a DB transaction and calls
ObjectManager#flush()
and ObjectManager#clear()
on the given EntityManager
.
Example (array iteration)
It can be used as following:
$record
freshness
Please note that the $record
inside the loop will always be "fresh"
(managed
state),
as the iterator re-fetches it on its own: this prevents you from having to
manually call ObjectManager#find()
on your own for every iteration.
Automatic flushing/clearing
In this example, the EntityManager
will be flushed and cleared only once,
but if there were more than 100 records, then it would flush (and clear) twice
or more.
Example (query/iterators)
The previous example is still not memory efficient, as we are operating on a pre-loaded array of objects loaded by the ORM.
We can use queries instead:
Or our own iterator/generator:
Both of these approaches are much more memory efficient.
All versions of doctrine-batch-utils with dependencies
doctrine/orm Version ^3.2.1
doctrine/persistence Version ^3.3.3