Keep track of database column changes.

I am working on a web application using the Zend framework.

I am looking for a way to keep a history of updates made to a bunch of columns.

Use case: User can add an item with 5 properties. User can update 5 properties. I need to keep track of all the updates it makes for these 5 properties.

While I was thinking about adding a new table called log that stores the old value, new value, column name, itemID and timestamp.

What is the best way to do this? Are there existing methods / options / examples?

Thank,

+3
source share
4 answers

, , , , - . MySQL.

, , : http://ronaldbradford.com/blog/auditing-your-mysql-data-2008-07-15/

, "". , , .

( , , ), , , , . , ... , .

+3

- , , . , . , , .

, , , . , , Zend, . ( familair Zend, , -, , , .)

+1

. .

0

Comp_Hist_Log, $ oldData = $array ('fieldname1', 'fieldname2')

AFTER_UPDATE gui hook .

sql ("INSERT INTO Comp_Hist_Log (Com_Rec_Id, old_data, new_data, ChangedDate, ChangedBy)

VALUES ('{$ data [' Record_Id ']}', '{$ oldData}', '{$ messageData}', '{$ data [' LastUpdated ']}', '{$ memberInfo [' username ']} ') ", $ eo); return TRUE;

Hope this helps ... it really works.

0
source

Source: https://habr.com/ru/post/1784593/


All Articles