How to keep history of record updates in MySQL?

后端 未结 6 814
南旧
南旧 2020-12-23 12:36

I have to create a code in PHP that will allow me to keep the history of record updates in MySQL database so I can find by date an old revision.

Here is the example

6条回答
  •  不知归路
    2020-12-23 12:52

    There is an open source (MIT license) framework to build CRM and ERP type of database driven web applications. You can download EPESI from http://epe.si/ available also on SourceFroge: http://sourceforge.net/projects/epesi/

    EPESI's CRUD engine - the Record Browser - has a very efficient record history as well as other features like advanced permission system (down to a field level) and much more.

    A single recordset stores data in as many as 10 tables and it is database agnostic (uses PHPAdoDB). A table called recordset_data stores "raw" data and history of changes is stored in 2 additional tables: recordset_edit_history and recordset_edit_history_data.

    Record's edit_history has the following structure:

    • ID (Primary key for this table, index)
    • Edited on (timestamp: 2008-05-14 15:18:15)
    • Edited by: (user ID)

    Record's edit_history_data has the following structure:

    • edit_id = ID from edit history
    • field = the name of the field that was changed
    • old_value = value of the field that changed.

    It is a very fast and efficient engine and it stores changes not on the record but on a single field level.

提交回复
热议问题