PHP code example of addiks / doctrine2_tweaks

1. Go to this page and download the library: Download addiks/doctrine2_tweaks 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/ */

    

addiks / doctrine2_tweaks example snippets




use Addiks\DoctrineTweaks\UnitOfWork\UnitOfWorkSaveState;

$saveState = new UnitOfWorkSaveState($entityManager->getUnitOfWork());

foreach ($thingsToImport as $counter => $thing) {

    $importer->import($thing); # Import a thing, add it to a collection or something

    if ($counter % 100 === 0) {
        $entityManager->flush(); # Send new entities to database
        $saveState->restore(); # Remove imported entities from unit-of-work
        gc_collect_cycles(); # Clean up memory
    }
}