Doctrine - How to print out the real sql, not just the prepared statement?

后端 未结 19 2381
自闭症患者
自闭症患者 2020-11-30 18:59

We\'re using Doctrine, a PHP ORM. I am creating a query like this:

$q = Doctrine_Query::create()->select(\'id\')->from(\'MyTable\');

19条回答
  •  遥遥无期
    2020-11-30 19:46

    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.

提交回复
热议问题