Gossamer Forum
Home : Products : DBMan : Customization :

Re: Adding more than one record at a time

Quote Reply
Re: Adding more than one record at a time In reply to
The following code opens the .count file, reads the contents and increments it:

Code:
open (ID, "<$db_id_file_name") or &cgierr("unable to open id file: $db_id_file_name.\nReason: $!");
if ($db_use_flock) { flock(ID, 1); }
$rec{$db_key} = <ID> + 1; # Get next ID number
close ID;

To write the new number to the .count file, use

Code:
open (ID, ">$db_id_file_name") or &cgierr("unable to open id file: $db_id_file_name.\nReason: $!");
if ($db_use_flock) {
flock(ID, 2) or &cgierr("unable to get exclusive lock on $db_id_file_name.\nReason: $!");
}
print ID $rec{$db_key}; # update counter.
close ID;

I'm assuming that you're doing this within sub html_record, so you would want to use the $rec{$db_key}.

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





Subject Author Views Date
Thread Adding more than one record at a time Sherwin 1412 Oct 15, 1999, 1:07 AM
Post Re: Adding more than one record at a time
Sherwin 1366 Oct 17, 1999, 1:55 AM
Post Re: Adding more than one record at a time
JPDeni 1364 Oct 17, 1999, 3:39 AM
Post Re: Adding more than one record at a time
Sherwin 1352 Oct 18, 1999, 8:59 AM
Post Re: Adding more than one record at a time
JPDeni 1366 Oct 18, 1999, 12:18 PM