Bruno Cantieni wrote:
> Hello all.
>> Our client runs a merchant network of 40+ merchants/catalogs.
> All the merchants catalogs are administered centrally (individual merchants
> have no admin functions other than basic order management) and many tables
> are global using a merchant_id field to identify individual merchant
> records.
> For ease of administration we would now also like the catalogs to read their
> rsp. variables from a "global" mysql variable table (keyed by
> catalog/merchant id) rather than from individual variable tables (currently
> using variable.gdbm) on restarts/reconfigs.
> While globalizing tables such as "products" was a no-brainer, I'm at a bit
> of a loss as to how we might implement this with "variable" or of it is even
> possible.
> Any thoughts on this would be appreciated.
You can add rows from an arbritrary database to the variabls:
# variable database
ParseVariables Yes
Database central central.txt __SQLDSN__
Database central USER __SQLUSER__
Database central PASS __SQLPASS__
ParseVariables No
NoImport central
VariableDatabase central
If you need changes immediately visible, you can put the values from
"central" into the variables namespace with an Autoload routine.
Example:
Sub <<EOS
sub load_settings {
$Tag->perl({tables => 'settings_names'});
my %other_keys = (base_url => 1,
default_mo => 1,
default_rabatt_1_shop => 1,
min_amount_artikeldaten => 1,
std_email_subj => 1,
dollar => 1);
my $set = $Db{settings_names}->query({sql => 'select * from settings_names', hashref => 1});
for (@$set) {
if ($_->{settings} =~ /^organization/ || $other_keys{$_->{settings}}) {
$::Variable->{uc($_->{settings})} = $_->{value};
}
}
}
EOS
Please consider the affect on the performance.
Bye
Racke