How to set up datatables with auditing fields

From CTRNet Wiki
Jump to: navigation, search

Any datatable can be set up to record created and modified information for each record. To do so, just add four fields to the datatable: "created_by" as an INT field, "created" as a DATETIME field, "modified_by" as an INT field, and "modified" as a DATETIME field.

CakePHP's built-in functionality will populate the "created" and "modified" fields with the current datetime on the addition of a new record, and update the "modified" field for any record being updated. This is an automatic function when using the regular Model->save() actions.

ATiM2 has a beforeSave() functionality in the app/app_model.php file that will populate the "created_by" and "modified_by" fields with the currently logged-in user on the addition of a new record, and update the "modified_by" field for any record being updated. This is an automatic function when using the regular Model->save() actions.

If the developer writes their own SQL, then these fields will not be populated.

There is no ATiM2 interface for accessing this auditing data.

For more information, visit the behaviour that this functionality was based on (specifically the beforeSave() action).

Personal tools