Doctrine - How to print out the real sql, not just the prepared statement?
A working example:
$qb = $this->createQueryBuilder('a');
$query=$qb->getQuery();
// SHOW SQL:
echo $query->getSQL();
// Show Parameters:
echo $query->getParameters();
Doctrine is not sending a "real SQL query" to the database server : it is actually using prepared statements, which means :
- Sending the statement, for it to be prepared (this is what is returned by
$query->getSql()
) - And, then, sending the parameters (returned by
$query->getParameters()
) - and executing the prepared statements
This means there is never a "real" SQL query on the PHP side — so, Doctrine cannot display it.