Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Re: Relational Mod

Quote Reply
Re: Relational Mod In reply to
Hi Jason,
I posted the original message of this thread asking if anyone had modified the relational DBMan mod for use with DBMan SQL.
After spending time setting up and using DBMan SQL (and reading 2 relational database design books and a MySQL book) I realized that there is no need for the DBman relational mod.
Just set up as many dadabases (tables) as you need using a common db.cgi file and seperate html.pl and config files.
Make sure each database (table) has a common field (I used userid). You can set the $db_table_user to the same in each config file so each database shares the same user names.
Make one of your html.pl files the default file and you can call up the data from any other database (table) by using something like -
# Connect to the database.
my $dbh = DBI->connect('DBI:mysql:database_name:host_name', 'user_name', 'password', {RaiseError => 1});

# This query will select the info we want.
my $query = qq!SELECT name, address, tel
FROM Location
WHERE table_name.userid = "$rec{'userid'}"!;
# Prepare the query.
my $sth = $dbh->prepare($query);

# Execute it.
$sth->execute();

# Get the results.
my ($name, $address, $tel);
print "Results:

";
while (($name, $address, $tel) = $sth->fetchrow_array) {
print "Name: $name
";
print "Address: $address
";
print "Tel: $tel
";

}

# Clean up
$sth->finish();
$dbh->disconnect();


This will call up the data from the same user in the database (table) you nominate in the FROM statement above.
I now have 5 databases (tables) related like this and they seem to be working fine. I haven't got to the search side of things yet but I guess it's just a matter of telling DBMan SQL where to look and what to search for.
You can set up each table by using the same nph-setup.cgi by calling the name of the config file -
http://www.yourdomain.com/dir/nph-setup.cgi?config=configfile_name.cfg
Hope this helps Smile
Simon.

Subject Author Views Date
Thread Relational Mod jai 3460 Jul 29, 2000, 5:10 PM
Thread Re: Relational Mod
Stealth 3352 Jul 29, 2000, 7:41 PM
Thread Re: Relational Mod
jai 3351 Jul 29, 2000, 9:30 PM
Thread Re: Relational Mod
Stealth 3345 Jul 30, 2000, 1:35 PM
Thread Re: Relational Mod
jdulberg 3315 Aug 9, 2000, 12:38 PM
Post Re: Relational Mod
jai 3318 Aug 9, 2000, 4:26 PM