This topic is locked

Delete a record but keep its physical record

10/3/2012 3:42:25 AM
PHPRunner General questions
W
wstai author

I want to delete a record but mark it instead of "real" delete its physical body.
A record will be hidden once its deleted mark is "Y" but its physical body still exists in the table.
Derrick 2012.10.3

Sergey Kornilov admin 10/3/2012

I think you can implement BeforeDelete event where instead of deleting record you can update it setting 'deleted' field to Y. You would also need to add a WHERE clause to your list page SQL query so it only shows non-deleted records:

select ... where deleted <> 'Y'


And here is the sample BeforeDelete event code:

CustomQuery("Update <table name> set deleted='Y' where ".$where);

return false;