Doctrine - how to get the SQL INSERT query, in the postSave() event?

后端 未结 5 933
一向
一向 2021-02-09 05:57

I would like to get the exact SQL INSERT query that Doctrine generates when an object\'s save() method is called.

Preferably, I would like to get it in the postSave() ev

5条回答
  •  攒了一身酷
    2021-02-09 06:35

    Take a look here: http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-8-hooks-profiling-dql and go to the section headed Profiling with Doctrine and Creating a Profiler Hook. Altough this is for the use with the CodeIgniter framework, it can be easy adopted to your own environment since the code has no dependencies to the framework.

    You basically want to set up a Connection Profiler and let it write all queries to a file. I suggest appending all queries to the file to have a better "log"-like feeling. Don't get confused by many framework talk inside the articles. The examples work very well (with a little understanding and copy&pasting) in other scenarios.

提交回复
热议问题