Thursday, December 10, 2015

How to print out the real sql in Doctrine and Symfony?

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
Show SQL: $sql=$query->getSQL();

Show Parameters: $parameters=$query->getParameters();
In this way, you can generate or print the real sql using Doctrine and Symfony. In my opinion, It will be much easy to debug the errors in the real sql than doctrine prepared query.
Source : http://stackoverflow.com/a/2095467

1 comment:

  1. Nice Information you have written here. Really Great Stuff. I keep it bookmark for our future purpose. Our Best Presence in Content Marketing Find our Content Writing Services in Nagpur & Content Writing Company in Nagpur .
    AceZed IT Solution

    ReplyDelete