Gossamer Forum
Home : Products : DBMan : Customization :

Archiving

Quote Reply
Archiving
Before using DBMan on commercial basis, I want to address a concern arising if a user was to modify records and then modify them again, without me backing up the database in the meantime.

Is there a feature -- or could a script addition provide such a feature -- where any changes are also appended to another database. I guess the logical conclusion of this would be for each update to cause the previous version to be appended to an archive database (with original loading date or other keywords being laid out with the field contents so as to provide automatic updating of an archive facility displaying all earlier editions of the user's records).

Does anyone have any ideas on at least a simple database append which keeps a history of all changes to allow for recovery or the manual production of an archive?

TIA,

Andy
Quote Reply
Re: Archiving In reply to
I don't think you could do an automatic recovery from the archive database unless you added another field for a separate key field. And even then, I don't know how you would go about it.

You could save the pre-modified records to a file, though.

In default.cfg, set the path and name of your archive db.

Code:
# Path and filename of archive database file
$db_archive_filename = $db_script_path . "/archive.db";

In db.cgi, sub mod, after

if ($data[$db_key_pos] eq $in{$db_key}) {

add

Code:
open (ARCH, ">>$db_archive_filename") or &cgierr("error in add_record.
unable to open database: $db_archive_filename.\nReason: $!");
if ($db_use_flock) {
flock(ARCH, 2) or &cgierr("unable to get exclusive lock on $db_archive_filename.\nReason: $!");
}
$archive = join($db_delim,@data) . $db_delim . &get_date . "\n";
print ARCH $archive;
close ARCH;

This will put the original, pre-modified record into the archive database, as well as the date of the addition. I'm not sure what else you would want.

------------------
JPD







[This message has been edited by JPDeni (edited July 05, 1999).]