One very old database maintenance rule basically says:
No entry should by removed from a database, but just marked as deleted.
|-- unknown author|
According to this rule, we may want to implement similar functionality also in phpMyEdit and it is possible, of course.
First of all we need to set-up phpMyEdit to list only valid non-deleted records. This can be accomplished using
$opts['filters'] configuration option. We suppose that we have table where a column named
deleted indicates if record is deleted or not.
Than we have to create a "delete before" trigger and we are done. Trigger PHP code should look similar to this example:
Example 6-4. Trigger for marking records as deleted
$query2 = sprintf('UPDATE %s SET deleted = 1 WHERE id = %d', $this->tb, $newvals['id']); $this->MyQuery($query2); return false;
To recover a particular record just change the value in the
deleted column from
0 using your SQL client or interface (for example using
Bootstrap phpMyEdit PHP Form Generator