Gossamer Forum
Home : Products : DBMan : Customization :

Dynamic Database Definitions

Quote Reply
Dynamic Database Definitions
Ok, I read and tried the Relational Database mod, it seemed to work ok but I don't think it is what I am looking for (although some of the sub routines in it may be handy for what I need to do).

I have 2 Databases:
Product Database
Fields{ModelNumber, Description, Picture}

Dealer Pricing Database
Fields{DealerName, DealerLocation, Pricing for Each Product}

What I want to do is have my "Database Definition" in the Dealer Pricing be built based on the # of products in the Product Database.

So if there are 10 Products, I want the "Database Definition" for the Pricing Database to add 10 Fields, 1 for each Product (and the fields should be named by the Product Model #) which would contain the Prices for each product.

That way each dealer can have their own price list based on the Product db.

Quote Reply
Re: Dynamic Database Definitions In reply to
I'm not too sure how to go about building the "Database Definition" of the Pricing Database based on the Model #'s in the Product Database. But here's a shot at it (mostly PseudoCode, because I'm not a Perl expert yet :).


%db_def = (
DealerName=> [0, 'alpha',40,255,1, '', ''],
DealerLocation=> [1, 'alpha',40,255,1, '', ''],
for (i=1, i<=Num_of_Products_in_Product_DB, i++)
{
(Read_in_Product_DB)Product => [i+1, 'alpha',40,255,1, '', '',]
}
);


Please help :)

Quote Reply
Re: Dynamic Database Definitions In reply to
Just one more thing to add before I hit the sack, I was browsing through the Unofficial dbMan FAQ and I found the "Building select fields with related data" document.

Following the document I tailored the code to what I need, and I was actually succesful in pulling the Data from the other database and outputting as I need it to, but I can only get it to output via the html.pl file. Here's a little snippet of the code I used:

foreach $field (sort @selectfields) {
$selected = 0;
foreach $value (@values) {
if ($value eq $field) {
$output .= "If one: $field
";
$selected = 1;
}
}
unless ($selected) {
$output .= "Product_$counter_i => [$counter_i, 'alpha', 40, 255, 1, '', ''],";
$output .= "
";
$counter_i++;
}
}

Any idea if I can somehow put this into the .CFG file to define my Database Definition?