Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between postUpdate and postPersist in doctrine

Whats the difference between postUpdate and postPersist events in Doctrine's event listener class? In my understanding, persist has to be done for both update and insertion. whats the benefit of having postUpdate then when one can handle this in the postPersist event?

like image 928
Obaid Maroof Avatar asked Dec 14 '22 20:12

Obaid Maroof


1 Answers

Because you should handle some logic only on update for example. And from doctrine's docs:

postPersist - The postPersist event occurs for an entity after the entity has been made persistent. It will be invoked after the database insert operations. Generated primary key values are available in the postPersist event.

postUpdate - The postUpdate event occurs after the database update operations to entity data. It is not called for a DQL UPDATE statement.

Do you see the difference now? The postPersist event is launched only after INSERT operations.

like image 162
slider_if Avatar answered Dec 17 '22 09:12

slider_if