Gossamer Forum
Home : Products : Links 2.0 : Customization :

Detail.cgi: Two Database Files?

Quote Reply
Detail.cgi: Two Database Files?
This Thread is a continuation from the following Thread:

http://www.gossamer-threads.com/...um3/HTML/003579.html

Okay...I have experimented with using a portion of the Relational Mod for DBMAN with LINKS in the detail.cgi script that Widgetz was kind to have written.

What I have done is the following:

1) Add two new sub-routines to the detail.cgi file:

Code:
sub switch_to_links {
#-----------------------------------------------------
@db_cols = qw(ID Title URL Date Category AltCategories Description 'Contact Name' 'Contact Email' Hits isNew isPopular Rating Votes ReceiveMail isDetailed isAward AwardDate);
$db_file_name = "/mnt/web/guide/anthrotech/cgibin/wwwvl/data/testlinks.db";
}

AND

Code:
sub switch_to_reviews {
#-----------------------------------------------------
@db_cols = qw(ReviewID Reviewer DateReviewed Navigation NavDescrip Graphics GraphDescrip Information InformDescrip Overall TotalScore);
$db_file_name = "/mnt/web/guide/anthrotech/cgibin/wwwvl/data/testreviews.db";
$db_key_pos = 0;
}

2) Added a new sub-routine where the fields are printed into a web page from the cgi script. I have added the following codes:

Code:
my (%rec) = &get_record ($in{'ID'});
&switch_to_reviews;
my (%rec2) = &get_record ($rec{'ReviewID'});
&switch_to_links;

I have also used codes like the following to print fields in the web page:

Code:
$rec{'Title'}

taken from the links.db file

AND

Code:
$rec2{'Reviewer'}

taken from the reviews.db file

You can see the complete script at the following URL:

www.anthrotech.com/tmp/testdetail.txt

My main goal is to print fields from the two databases into one detailed view for each record. The common field between the databases is the "ID" field signified as ID in links.def and ReviewID in reviews.def.

Anyone have ideas about how to make this work?

Thanks in advance.

Regards.

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
The last time I looked at Widgetz's Review It script, it replaced Rate It, which I can't do. But it sounds like what you are up to could be a work around for that problem.

I won't be much help designing the mod but you have my complete moral support. Wink

------------------
Will
Webmaster
FishHoo! Search index for Fishermen
www.fishhoo.com
Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
ok.. i might be going too much into Links SQL on this one.. but if you created an object for each .def file you could use them at the same time without your switch to thingies..

jerry
Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
Thanks for the suggestion, Widgetz. Could you be more specific? Again, I am not well versed in SQL, so any assistance would be helpful.

Thank you for your time.

Regards.

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
i'm not talking about SQL..

i'm talking about perl..

if you made links.def into an object for example ($links)..

then you could say like

%rec = $links->get_record ($ID);

of course you'd have to make a huge packaged library..

still.. to save your time you could just buy Links SQL..

jerry
Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
Well, I got it to work...All I needed to do was to name the db_key (ID) the same for both databases. Then I experimented and created a third database called des.db. I created a third switch sub-routine and it worked!

While this method does use more bandwidth than MySQL, it may prove to be a nice Mod for those people who do not have access to MySQL.

Although the coding is not that simple and it is chunky. But it works....

Until I upgrade, this may prove to be a temporary solution.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
Hi Eliot,

Is there an example of how you are using this on your site?

Does ID "number itself" has to be the same in both databases in order to tie them together? Makes sense if you are storing a part of the record in one database and the other part in the second database.

What I would like to do is to have a full company profile in one database. The second database contains the classified listing, which expires after a set period. But I would like to be able to display the profile from the first database on the second database (classifieds). The problem is that the ID in the second (classifeds) database will keep changing. So, by using your mod can I accomplish this?

Appreciate you reply.
Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
socrates,

Yes...the ID has to be the same between the databases. This mod will do what you want.

However, there are some glitches in the Mod:

1) There is essentially no way at this time to dynamically delete records from both databases. They can only be deleted from one. I am not too concerned since I am using this Mod for an administrative Site Review script. (I will be using DBMAN as a front end for the Site Reviews, which will write data to the reviews.db file.)

2) It does not list records in one table of contents. This is something that I will playing around with in the next few weeks.

3) There is room for error because you have to manually input the record number of the associated record in the links.db file.

4) It is uses more bandwidth than using SQL or object oriented Perl codes.

This Mod is not easy to implement nor is it foul proof. Yet it does suit my needs.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited December 19, 1999).]

[This message has been edited by Eliot (edited December 19, 1999).]
Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
Hi Elliot!

Seeing this forum is roughly along the samelines as I am looking for - I thought I ask my question here.

I have two link dbs. Each one with their own home.html. Each has different information contained.

How can I make one main home.html with both sets of categories/subcategories showing?



------------------
www.nzcid.godzone.net.nz
New Zealand Christian Internet Directory




Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
Rough...to say the least, Ian.

One suggestion is to try using the category.cgi script that Widgetz wrote.

Look at the problems I've posted with this particular "Mod"....Many...and I have gotten the script to work, but in a very clumpsy manner.

I am definitely NOT in a position to release the codes that I wrote for this Mod.

Wink

Sorry.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------









Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
Hi Elliot!

Thanks for the comments. There appears to have been numerable discussions on how to run multiple databases with links. No one appears in all the forums I could find has actually come up with a good working solution that could be adopted by others.

Spoken by email to some of those who started the conversation and none reached a satisfactory conclusion.

Before someone informs me of SQL capability I am aware it can handle multiple databases, however our DB's will never reach the stage of needing something like a SQL version for a very long time.



------------------
www.nzcid.godzone.net.nz
New Zealand Christian Internet Directory




Quote Reply
Re: Detail.cgi: Two Database Files? In reply to
That is correct. Sorry...but my script is very clumpsy.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------