Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Relational Mod

Quote Reply
Relational Mod
Has anyone implimented the standard DBMan relational mod with DBMan SQL. If so, what changes were needed? If not, does anyone know if it can be done?
Thanks.
Simon.

Quote Reply
Re: Relational Mod In reply to
What you will have to do is the following:

1) Create another table/database to store the data (with the ID or another unique field being the primary key of both databases/tables).
2) Then change the codes that JPDeni to parse data from the new table/database.

Regards,

Eliot Lee

Quote Reply
Re: Relational Mod In reply to
Hi,
I guess what you are saying is that it can be done.
Please explain in a little more detail exactly what I would have to do.
Thanks
Simon.

Quote Reply
Re: Relational Mod In reply to
For creating the new tables, I would recommend downloading, installing, and using MySQLMan found in the Products section of this site. After you have created a new table, then we can proceed to help you with the next steps.

Regards,

Eliot Lee

Quote Reply
Re: Relational Mod In reply to
I'm also interested in getting the relational mod to work using dbman sql. I'm working on a realestate listings db for my client. Relating a listing to an agents bio would be a nice addition.

I look forward to your instructions.

-----------
Jason Dulberg
Extreme MTB
http://extreme.nas.net
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.