Gossamer Forum
Home : Products : DBMan : Installation :

Build Archive DB

Quote Reply
Build Archive DB
Hi all,
I got the DB working the way I want, mainly because of all the help here on forum. One
thing I would like to do is create an Archive db. When a record is deleted, I would like to add the deleted record to another db file. Is this possible? If so can
someone point me in the right direction.
I have some ideas but I'm kinda afraid to mess things up.
Thanks for all the help.
PB:-)
Quote Reply
Re: Build Archive DB In reply to
You could copy the "add_record" routine and put it within the "delete_record" routine. You'd have to explicitly state the file name, though. You couldn't use the variable.

As for messing things up, just be sure to keep a copy of your old db.cgi file in case there's a problem. Then play around with your copy as much as you want. You can't do any *real* damage. (Maybe you should also backup you .db file, though, just for saftey. Smile )

------------------
JPD
Quote Reply
Re: Build Archive DB In reply to
Hi JPDeni,
Thanks once again for help. I got it working
somewhat, which kinda surprised me:-).
But now I'm stuck. I created a subr called
add_delete_record:
sub add_record_delete {
# --------------------------------------------------------
# Adds a record to the archive database.



my ($output);
open (FileDB, ">>$db_script_path/delete.db");
print FileDB &join_encode(%in);
close FileDB;

}

I then added it at the end of the html_delete in the html.pl:

for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_,@hits);
print qq|<TD><INPUT TYPE=RADIO NAME="$tmp{$db_key}" VALUE="delete"></TD><p>|;
&html_record_long(%tmp);
&add_record_delete;
}
It actually wrote to the delete.db. But it
only wrote the record ID(see below)

19&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;|
20&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;&#0124; &#0124;|

I feel I'm so close, but I'm not sure what to do now. Can you help?
Thank again.
PB:-)
C

Quote Reply
Re: Build Archive DB In reply to
Excellent! You're definitely on your way!!

Just a couple of little things and you'll be there.

In your sub add_record_delete, change

print FileDB &join_encode(%in);

to

print FileDB &join_encode(%tmp);

The only trouble you might have is that it saves the record to your archive db before you've actually deleted the records. If you delete everything that is returned from a search, you'll be okay.

There's another way to go that could be really slick. In db.cgi, sub delete_records, find

Code:
$delete_list{$data[$db_key_pos]} ?
($delete_list{$data[$db_key_pos]} = 0) :
($output .= $line . "\n");

(I took out the comments at the end of the lines here.)

and replace it with

Code:
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0;
open (FileDB, >>$db_script_path/delete.db");
print FileDB $line . "\n";
close FileDB;
}
else {
$output .= $line . "\n";
}

(I'm not enough of a Perl programmer to be able to work around all the shortcuts. I'm lucky to be able to understand them! Smile )

This at least gives you some options. I haven't tried the code and my track record hasn't been too good lately, so I'm not guaranteeing a thing! Smile






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


[This message has been edited by JPDeni (edited February 17, 1999).]
Quote Reply
Re: Build Archive DB In reply to
Hi JPDeni,

>>There's another way to go that could be really slick. In db.cgi, sub delete_records, find.....<<

Well you came thru again, that fix works perfectly. I really don't how to thank you.
You are simply amazing. Thank you so much.
I know this sounds kinda ridiculous, but if
I can ever help you please let me know:-)
Take care.
PB:-)


Quote Reply
Re: Build Archive DB In reply to
Thank you so much for your kind words. I look at DBMan (and programming in general) as a puzzle to be solved -- and I just love puzzles! Smile

It's not ridiculous at all for you to offer to help me. Who knows what problems I could have in the future that you are an expert in?

But, in the meantime, I like to think of my help here as being "kindness-ware." As payment for my help to you (and this applies to everyone, although I haven't said it before), go out of your way to show kindness to someone today. Read a book to a child, do a household chore when it isn't "your turn," open a door for someone -- whatever opportunity you have to show some kindness to someone you love or to a stranger. If this will cause even one person to take the time to be a little nicer to someone else, then the whole world is just a little better and that is plenty of payment for me.

Okay. I'll get off my "touchy-feely" soapbox for now. Smile Glad I could help!


------------------
JPD
Quote Reply
Re: Build Archive DB In reply to
Yeah! most of us here will have to
show their kindness everyday~ That's a great
step for the software industry! Smile I love
this idea so much!