Gossamer Forum
Home : Products : DBMan : Customization :

More relational DB woes

Quote Reply
More relational DB woes
I'm using the relational mod to relate the following databases:

1. bikereviews -> bike comments : users relates to both
2. trailreviews -> trail comments : users relates to both

With a great deal of help from JPDeni, the first set of db's works pretty well. So I figured that I'd just copy the bike stuff and modify them to fit with trail reviews. I added the switches to the db.cgi as well.

Here's the problem. "trail comments" are supposed to display under "trail reviews" however - they aren't. I changed the switch and cfg files according to the names of the new db's. For instance, "ReviewID" was the common field in my bike db's -- so I just changed it to "TrailID". Didn't work though.

Here's what I have for my "trail comments" cfg: (took out some of the fields to shorten the post)

trailcommentID => [0, 'numer', 5, 8, 1, '', ''],
trailcommentUserid => [6,'alpha', -2, 15, 0, '', ''],
trailcommentValidated => [7,'alpha', 0, 3, 0, 'No', 'Yes|No'],
TrailID => [8, 'numer', 5, 8, 1, '', '']

$db_key = 'trailcommentID';

Here's my trailreviews cfg. I'll only post a couple of the entries 'cuz there's 15 of 'em.

TrailID => [0, 'numer', 5, 8, 1, '', ''],
Userid => [14,'alpha', -2, 15, 0, '', ''],
Validated => [15,'alpha', 0, 3, 0, 'No', 'Yes|No']

$db_key = 'TrailID';

This is what I have in the trailreviews_html.pl at the part where its supposed to scoop the trail comments:

&switch_to_comments_trailreviews;
undef %in;
$in{'TrailID'} = $rec{'TrailID'};
$in{'trailcommentValidated'} = 'Yes';
$in{'so'} = 'descend';
$in{'mh'} = 100;
my ($status2,@hits2) = &query("view");
if ($status2 eq "ok") {
my ($numhits2) = ($#hits2+1) / ($#db_cols+1);
%rec2 = &array_to_hash($_, @hits2);

I'm using %rec2 in the bikereviews db but I figured that since the trails and bikes db's aren't related, I don't need to change it to %rec4 or something. (I tried it but it didn't do anything).

So the stuff that should display, I just put something like $rec2{'trailcommentUserid'} etc.

I uploaded all of my db files to the server to clarify my problem.

Working version at:
http://visit-my-webpage.com/....cgi?db=trailreviews

Setup files at:
http://www.visit-my-webpage.com/tmp/

When I add a comment to a trailreview (db switches to the comments db), pulling the original trailreview data into the trail "comment" works okay - reversing it doesn't work.

I've been messing with it for a few days now in attempt to fix it myself but its a no go.

This "should" be my last relational db for my site. Once again, thanks for all the help!!

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: More relational DB woes In reply to
I can't seem to log on to your database, nor to retrieve my password, nor to create a new one.

The code that you posted looks fine and there's nothing in the .cfg file that looks wrong. Possibly if I could see the whole html.pl file, I might be able to find something.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: More relational DB woes In reply to
Sorry, log in as - admin/admin

I just created an account with no problem. Did it cough up an error on you?

All of the cfg/html files are in the tmp directory. The link in my original post takes you there.

I really appreciate all of your help in getting my db's working.

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: More relational DB woes In reply to
Yes. I had trouble signing up for a password. It said that "jpdeni" was not an appropriate password and that my email address was in the file. But when I tried to get a new password, it said my email address was not in the file. So I'm not sure what's up with that.

The files that I see in http://www.visit-my-webpage.com/tmp/ are

bikereviews.cfg.txt
bikereviews.db.txt
commentsbikereviews.cfg.txt
commentstrailreviews.cfg.txt
db.cgi.txt
trailreviews.cfg.txt
users.cfg.txt

I think the one I need to look at is trailreviews_html.pl, if you're having trouble with the comments coming up with the reviews.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: More relational DB woes In reply to
Ooops, sorry about that. I thought I had uploaded them. All of the files are there now.

I don't know what the problem could be with signing up. I made a test account with no problem. I looked at the .pass file and there is nothing of yours in there. I saw in the .log file that you were able to log in. Said it was 31-Dec-1969 but thats a different fix (I saw a post about it before).

Let me know if your having any other login probs.

Thanks again...

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: More relational DB woes In reply to
I think I found your problem.

Code:

sub switch_to_comments_trailreviews {
#-----------------------------------------------------
$cols = 'trailcommentID,trailcommentName,trailcommentEmail,...';
@db_cols = split /,/,$cols;
$db_file_name = $db_script_path . "/data/comments_bikereviews.db";
$db_key_pos = 0;
$db_validated_field = 'trailcommentValidated';
}
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: More relational DB woes In reply to
Now I feel like a dumbass. That was it!! Good eye!

While I've got you... I have another relational mod question.

On the signup page, there's an option for making their profile (users db) either public or private. I haven't really worked it into the db yet - my question is, how hard would it be to actually implement it?

The person's username is posted on their bio and anything else that they post (in any db). I'm guessing that this would require something like a "global if" statement. Technically, I guess when a record is displayed, its gonna have to switch to the users db, check to see if "IsPublic" is yes or no, switch back and if yes, the username is clickable, if no, username isn't clickable.

I already have what you gave me before so would it be possible to just modify it? Here's what I have.

&switch_to_users;
%rec3 = &get_record($rec2{'trailcommentUserid'});
&switch_to_comments_trailreviews;
if ($rec3{'Userid'}) {
print qq|<td><$font><A HREF="$db_script_url?db=users&uid=$db_uid&view_records=View+Records&Userid=$rec3{'Userid'}">$rec2{'trailcommentName'}</a></font></td></tr>|;
}
else {
print qq|<td><$font>$rec2{'trailcommentName'}</font></td>|;
}

How can I make it so if it finds the username, it checks to see whether or not it should actually put in the link?

Did that make any sense? Its pretty late here so the 'ol brain juices aren't flowing too well.

Thanks again!

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: More relational DB woes In reply to
In Reply To:
While I've got you... I have another relational mod question.
Uh-oh. That always means trouble. Wink

In Reply To:
Technically, I guess when a record is displayed, its gonna have to switch to the users db, check to see if "IsPublic" is yes or no, switch back and if yes, the username is clickable, if no, username isn't clickable.
Right.

In Reply To:
How can I make it so if it finds the username, it checks to see whether or not it should actually put in the link?
Code:

&switch_to_users;
%rec3 = &get_record($rec2{'trailcommentUserid'});
&switch_to_comments_trailreviews;
if (($rec3{'Userid'} ) && ($rec3{'isPublic'} eq "yes")) {
print qq|<td><$font><A HREF="$db_script_url?db=users&uid=$db_uid&view_records=View+Records&Userid=$rec3{'Userid'}">$rec2{'trailcommentName'}</a></font></td></tr>|;
}
else {
print qq|<td><$font>$rec2{'trailcommentName'}</font></td>|;
}
Make sure that yes is correct. If your response can be "Yes" or "YES," change it in the code above to match.



JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: More relational DB woes In reply to
In Reply To:
Uh-oh. That always means trouble.
Yep, I'm a dbman trouble maker. Always causing unnecessary frustration

I thought getting that isPublic thing to work would be much more of a pain. You made it look sooo simple! Works like a charm!

Thanks!

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
Quote Reply
Re: More relational DB woes In reply to
When I started writing that post, I thought it was going to be more of a pain, too. Smile Then the
&& thing occurred to me and I realized it was pretty simple.

Glad to help, Jason.


JPD
http://www.jpdeni.com/dbman/