ferpega
ferpega

Reputation: 3224

Doctrine2 how to see a generated createQuery SQL Text (symfony2)

I would like to get the 'real' SQL Query doctrine is passing to the SQL Server:

<?php
$em = $this->getDoctrine()->getEntityManager();

$myQuery = $em->createQuery('SELECT v FROM ....... v');
echo $myQuery->???????

?>

What I must to write instead of ???????? characters ?

I have tried with getSQLQuery() and with getSQL() but no luck for now.

Thanks..

Upvotes: 1

Views: 5673

Answers (3)

user4183470
user4183470

Reputation: 1

See if it helps

$myQuery->getDql();

Upvotes: 0

Banana
Banana

Reputation: 11

You could try this:

$myQuery->getResult();

Upvotes: 1

Benevolensky
Benevolensky

Reputation: 81

You were almost there, it's getSql, not getSQL:

$myQuery->getSql()

Upvotes: 8

Related Questions