<?php
use PHPSnippets\Db\Entity\Test;
// DebugStack logger is enabled to show all executed queries
// @see http://php.budgegeria.de/qbpgevarybttre
echo '<b>get Entity Reference with id 1</b>' . PHP_EOL;
$ref = $entityManager->getReference(Test::CLASS, 1);
echo $getCurrentSqlQuery();
echo '<b>Now we access the reference\'s data</b>' . PHP_EOL . PHP_EOL;
echo sprintf('<b>id: %d, name: %s</b>' . PHP_EOL, $ref->id, $ref->name);
echo $getCurrentSqlQuery();
Result
get Entity Reference with id 1
count of executed queries: 0
no sql queries were executed
Now we access the reference's data
id: 1, name: foo
count of executed queries: 1
query: SELECT t0.id AS id_1, t0.name AS name_2, t0.creation_date AS creation_date_3 FROM test t0 WHERE t0.id = ?, params: [1]