How to set up datatables for soft-deletes

From CTRNet Wiki
Jump to: navigation, search

Any datatable in ATiM2 can be set up for soft/logical deletes by simply adding two fields: "deleted" as an INT field, and "deleted_date" as a DATETIME field.

Any datatable with these two fields will not have their rows deleted through use of CakePHP's regular Model->del() function. A behaviour added to the /app/app_model.php file will "see" any delete calls of that fashion; it will instead change the value of "deleted" to "1" and change the value of "deleted_date" to the current datetime. The behaviour will also capture any Model->find() calls and ignore any row of any datatable which has a value of "1" in an existing "deleted" field.

And datatable without these two fields will be deleted as normal. Developers who write custom SQL for deletes will have use the "Deleted" fields manually. This behaviour only works through the regular CakePHP Model->action calls.

There is no ATiM2 interface for accessing these soft-deleted rows.

For more information, visit the behaviour's CakePHP Bakery page

Personal tools