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


I would like to get the exact SQL INSERT query when the principle is saved to a () method.

Preferably, I want to get it in the PostSave () event of the model and would like to log it into a txt file.

For example:

  & lt ;; Php $ user = new user (); // A principle model with timestamp behavior $ user enabled- & gt; First_name = 'manny'; $ User- & gt; Last_name = 'calvar'; $ User- & gt; Save (); ? & Gt;  

I want to receive / log the following SQL queries:

  Log in user (first_name, last_name, created, updated) value ('Manny', '' Kailwara ',' 2010-08-03 12:00:00 ',' 2010-08-03 12:00:00 ');  

Background requirement is that I want to import a large amount of data after parsing the TST file and after the data.

I do not think there is any easy way to do this because the behavior of saving is something different (if you insert / Updates).

If you have created a theory query object, you can call the getSqlQuery () method like this:

  $ q = Doctrine_Query :: create () - & Gt; Select ('u.id') - & gt; From ('User You'); Echo $ q- & gt; GetSqlQuery ();  

But save () is a method, not an object, so it will not work. I think you have to hack into some code to find out whether you insert or update and create a query and then use the save () to log on the fly.

I know that this suggestion is not ideal because it is doing 'right' what is not saving (), but for the purposes stated by you, it should still work properly.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -