hi guys, interesting information and ideas
I just wanna share my way of doing this when i needed it a while ago
1- clone the main table you you want to keep track (e.g. mysql operations > copy table) name e.g. table_history
2- very important: add a new field in your new table name it e.g. updateid…make it primary and AI instead of your copied one of the original table… this is not to mix with the primary key of the original table that you are getting the data from…
— moreover, you can exclude the the primary key field of the original table if you like… or rename it to “id_original_table”…
3- add one more field as timestamp - default: update datetime
4- in your original form > events > on afterupdate > the right side pre-made codes “insert a record on another table”
basically you will need something like this:
$insert_table = 'table_history';
$insert_fields = array(
'id_in_original_table' => "'{id}'", \\ this is your primary key in the original table... is not needed there in history i think...
'field1' => "'{field1}'",
'field2' => "'{field2}'",
'field3' => "'{field3}'",
'field4' => "'{field4}'",
'field5' => "'{field5}'",
'user' => "'[usr_name]'",
);
$insert_sql = 'INSERT INTO ' . $insert_table
. ' (' . implode(', ', array_keys($insert_fields)) . ')'
. ' VALUES (' . implode(', ', array_values($insert_fields)) . ')';
sc_exec_sql($insert_sql);
fields on the left should be from the history table, and from the right are your fields of the original table {}
5- make some updates, see if data all goes ok and/or adjust as per your need
6- create new grid based on the history table to customize to filter the history you need and make it start by search for example to filter the huge data if any
looks like a log module, but that one registers everything, this one can be adjusted to the need
Cheers
Mike