Hello guys,
i am trying to figure out a way to create audit tables for some of my project tables (orders, users, etc) in which i write each time an entry gets updated.
I have read quite a bit around and tried to make that using database triggers as a cleaner way, but that just has too many things that do not suite me.
So i decided to use the framework and implement table audits myself using CI4 model events. using afterInsert, afterUpdate, afterDelete seems to be a greate way to do it, however the data passed to those events is only the data which changes (which is awesome to have) - but i am looking at a way to get the original row, thats being updated. This way in my audit table i can have the old (original) row, and additional columns: who, when and what was changed.
While working with Entities makes that somewhat possible (since Entities have the "original" property) - this quickly gets out of hand if i try to make a simple query that does not make use of the Entities - say i want to mass update order status for 500 orders or something.
I am quite stuck and just cant figure out a relatively efficient way of doing that.
I always thought that this should be somewhat generic and expected to find tons of solutions - however that does not seem to be the case
)
Anyone has any ideas?