Platon Technologies
neprihlásený Prihlásiť Registrácia
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Utorok, 30. november 2021
O nás
Otvorený softvér
Index  »  Projekty  »  phpMyEdit  »  Dokumentácia  »  HTML  »  Data removal protection

6.3. Data removal protection

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.

Example 6-3. Non-deleted records listing

$opts['filters'] = 'deleted IS NULL OR deleted = 0';

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']);
return false;

To recover a particular record just change the value in the deleted column from 1 to 0 using your SQL client or interface (for example using phpMyAdmin).

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov