I'm using Doctrine to save user data and I want to have a last modification
field.
Here is the pseudo-code for how I would like to save the form once the user presses Save
:
- start transaction
- do a lot of things, possibly querying the database, possibly not
- if anything will be changed by this transaction
- modify a
last updated
field
- modify a
- commit transaction
The problematic part is if anything will be changed by this transaction
. Can Doctrine give me such information?
How can I tell if entities have changed in the current transaction?
edit
Just to clear things up, I'm trying to modify a field called lastUpdated
in an entity called User
if any entity (including but not limited to User
) will be changed once the currect transaction is commited. In other words, if I start a transaction and modify the field called nbCars
of an entity called Garage
, I wish to update the lastUpdated
field of the User
entity even though that entity hasn't been modified.