PHPackages                             addiks/doctrine2\_tweaks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. addiks/doctrine2\_tweaks

ActiveLibrary[Database &amp; ORM](/categories/database)

addiks/doctrine2\_tweaks
========================

Some component-replacements with tweaks and modified behaviour for the doctrine2 project.

v1.0.0(2y ago)01.9kGPL-3.0PHPPHP &gt;=8.0.0CI failing

Since Feb 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/addiks/doctrine2_tweaks)[ Packagist](https://packagist.org/packages/addiks/doctrine2_tweaks)[ Docs](http://addiks.net/doctrine2_tweaks)[ RSS](/packages/addiks-doctrine2-tweaks/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (7)Used By (0)

Doctrine2-Tweaks
================

[](#doctrine2-tweaks)

[![Build Status](https://camo.githubusercontent.com/eb984376545550d3a96e2dd84e2e140bd75841f7e78557fe5bded0a8f5278159/68747470733a2f2f7472617669732d63692e6f72672f616464696b732f646f637472696e65325f747765616b732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/addiks/doctrine2_tweaks)

This repository represents a collection of alternative components with tweaks and/or changed behaviour for the doctrine2-project.

UnitOfWork Save-State
=====================

[](#unitofwork-save-state)

**Addiks\\DoctrineTweaks\\UnitOfWork\\UnitOfWorkSaveState**

This represents a save-state of a doctrine unit-of-work instance. Using this, you can always revert the state of a unit-of-work instance back to a previous state.

This can be useful for bulk-operations: Create a save-state at the beginning of the bulk-process and then restore it after every flush. That way the unit-of-work will never contain objects that were already flushed, saving memory and (execution-)time.

This differs from a simple entity-manager `clear` call because it leaves all objects in the unit-of-work that were in it when the save state was created. Keeping these objects in it can (and often will) help with keeping the state of the unit-of-work consistent with the rest of the application.

Remember to also call "gc\_collect\_cycles()" when restoring to actually free the memory.

Example:

```
