Get the SQL for a Doctrine 2 entity insert

doctrine-orm

Solution

You could activate the query log in your MySQL server (guessing it's it) : in /etc/mysql/my.ini (usual place) :

[mysqld]
log=/tmp/mysql.log

then read this file where you will find each issued query.

Problem

Is it possible to get the SQL for a Doctrine 2 entity insert? For example, let's say I have this: ``` $foo = new Foo(); $foo->setName('bar'); $em->persist($foo); $em->flush(); ``` Is there a way to get the SQL for the INSERT statement there? If so, how?

Original source