Treuer Germane
New Member
I'm looking for a way of making simple event log for my tables. I have few tables that can be changed by various users, and I want to keep track on:\[code\]- who made the change- when - what was before update- what is the new value- which table and which record & column\[/code\]somthing like will be great:\[code\]20:00:00 | john | update | products | 113 | product_name | "xbox" | "xbox 360"20:00:10 | jim | update | products | 113 | product_name | "xbox 360" | ""20:01:00 | jim | delete | products | 113\[/code\]So i read that triggers could be the answer but as far as I read it seems that I need to have a complete new table for each column I want to keep track on. Triggers are not perfect for this job also because I want to log who made the change, and from what I read this is not possible.I thought of making 3 different functions for CRUD (insert, update, delete), and just before making the query, to check what is changed and to make the log and then run the query. But from here it seems to be very slow and complicated.Is there another better way ?ThanksOk, I checked again the triggers and its not what I was looking for, so I wrote simple functions that will check for each query you want to log if the new values are different, and if so - it logs it.The main problem is, and I didn't measure it, but it obviously slower.first you need to make a new mysql table as follow:
- id (a_i, primary)
- creation_date (datetime)
- user_id (int)
- table_name (tinytext)
- record_id (int)
- cell_name (tinytext)
- action_type (tinytext)
- old_value (text)
- new_value (text)