<?php
use PHPSnippets\Db\Entity\Test;
use Doctrine\DBAL\Logging\DebugStack;
$logger = new DebugStack();
$entityManager->getConnection()
->getConfiguration()
->setSQLLogger($logger);
$entity = $entityManager->find(Test::CLASS, 2);
$current = $logger->queries[$logger->currentQuery];
echo sprintf(
'<b>query:</b> %s, <b>params:</b> [%s]',
$current['sql'],
implode($current['params'])
);
Result
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: [2]