PHP code example of plumphp / plum-doctrine

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

    

plumphp / plum-doctrine example snippets


use Plum\PlumDoctrine\ORM\EntityWriter;

$writer = new EntityWriter($entityManager);
$writer->prepare();
$writer->writeItem($user1); // persist, but no flush
$writer->writeItem($user2); // persist, but no flush
$writer->finish(); // flush

use Plum\PlumDoctrine\ORM\EntityWriter;

$writer = new EntityWriter($entityManager, ['flushInterval' => 3);
$writer->prepare();
$writer->writeItem($user1); // persist, but no flush
$writer->writeItem($user2); // persist, but no flush
$writer->writeItem($user3); // persist and flush
$writer->writeItem($user4); // persist, but no flush
$writer->finish(); // flush

use Plum\PlumDoctrine\ORM\QueryReader;

$reader = new QueryReader($query);
$reader->getIterator(); // -> ArrayIterator<object>
$reader->count(); // -> int

use Plum\PlumDoctrine\ORM\QueryReader;

$reader = new QueryReader($query, ['hydrationMode' => Doctrine\ORM\Query::HYDRATE_ARRAY);
$reader->getIterator(); // -> ArrayIterator<array>

use Plum\PlumDoctrine\ORM\RepositoryReader;

$reader = new RepositoryReader($repository, ['age' => 20]);
$reader->getIterator(); // -> ArrayIterator
$reader->count(); // -> int