I have to log every database action on my log table, here is the table:
log_id - INT
user_id - INT
table - VARCHAR(45)
date - INT
action - ENUM('INSERT','DELETE','UPDATE')
new_value - VARCHAR(255)
old_value - VARCHAR(255)
If a user create a new blog post, for instance, I have to save the user id, the table where the object will be inserted, date, action will be "INSERT", new_value will be the php object serialized, the old_value will be empty.
In the case of a update, I need to save the new_value with the new object but before that I need to save the current values, also serialized on the old_value column.
In the case of a delete, I need to save the serialized object on the old_value column and leave the new_value empty.
I was reading about CI Hooks but it seems it doesn't work with database actions, only with controllers and system. Is there a way to use hooks or there is a better solution?
Thanks in advance for any help.
Sorry about the long description, I'm not good with words.