<?php
use PHPSnippets\Db\Entity\Test;
// get Test entity with id 1
$entity = $entityManager->find(Test::CLASS, 1);
echo sprintf(
'<b>id: %d, name: %s</b>' . PHP_EOL,
$entity->id,
$entity->name
);
// create new Test with same id as $entity
// but with different name and date
$test = new Test();
$test->id = 1;
$test->name = 'merged';
$entityManager->merge($test);
// after merge, $entity with id 1 got the values of $test.
// $entityManager->flush() will update it in DB
echo sprintf(
'<b>id: %d, name: %s</b>' . PHP_EOL,
$entity->id,
$entity->name
);