I am using Propel 1.6 and have a need to version all tables in a particular database. I have a number of tables, each having a versionable table defined in the schema (so table 'role' has a table 'role_versionable' as its versioning counterpart). When saving a record in 'role' I would like to copy the existing record to role_versionable before doing the save.
This is in itself trivial to do: I've set the baseClass for the whole schema to a custom class (which extends BaseObject) and all my generated row model classes extend this class. In my custom save routine I am doing a fresh select and then saving that to the versionable table. However I should be able to intercept doSelect[One] in all row classes, but I don't want to have to generate child objects for every table in the model.
I am therefore wondering if there is a way I can hook into a postSelect or get called automatically after every doSelect, to grab the initial state of the object after it is selected? This will then save me the extra select when I come to version the row.
(Detail: I am doing this in a custom way as I need to add extra metadata to the version table, which I don't believe the archive_behaviour supports.)
AFAIK there is no way to use a hook before or after a call to doSelect
. Your best chance is to override this method in your own class and to add a hook by yourself. I'll probably write my own Peer builder to do that.
William