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

后端 未结 19 2389
自闭症患者
自闭症患者 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:45

    There is no other real query, this is how prepared statements work. The values are bound in the database server, not in the application layer.

    See my answer to this question: In PHP with PDO, how to check the final SQL parametrized query?

    (Repeated here for convenience:)

    Using prepared statements with parametrised values is not simply another way to dynamically create a string of SQL. You create a prepared statement at the database, and then send the parameter values alone.

    So what is probably sent to the database will be a PREPARE ..., then SET ... and finally EXECUTE ....

    You won't be able to get some SQL string like SELECT * FROM ..., even if it would produce equivalent results, because no such query was ever actually sent to the database.

提交回复
热议问题