MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

SQL product database with other table name




Hello, MiniVendors !

For www.materialboerse.de I struggled to mate MiniVend with a SQL product
database. The table name is component, not products. I patched 
MiniVend. I don't know if I overlooked a more simple or elegant
solution, but the best way I found is the following:

minivend.cfg:
---------------------------------------------------------------------
UserTag foo Routine <<EOR
sub {
	package Vend::Config;

	sub parse_erasevalue {
		my ($dummy, $directive) = @_;
		my $directives = catalog_directives();
		my ($parse, $name);

		foreach my $d (@$directives) {
			next unless (lc $directive) eq (lc $d->[0]);
			$name = $d->[0];
			$parse = $d->[1];
			last;
		}	

		if ($parse eq 'database') {
			$C->{$directive} = {};	
        } else {
            $C->{$directive} = '';
        }
		return $directive;
	}
}
EOR

AddDirective EraseValue erasevalue
---------------------------------------------------------------------

catalog.cfg:
---------------------------------------------------------------------
EraseValue Database
#Database            products  products.asc  TAB
Database            pricing   pricing.asc   TAB
#Database            inventory inventory.asc TAB
#Database            userdb    userdb.asc    TAB
Database            seek       seek.asc      TAB

# Here are some sample product database definitions for various SQL 
# database types. These might even work for you if the SQL package
# in question has an existing data source with that name -- these
# may be the defaults in the distributed packages.
#
# For mSQL to work you would do:  msqladmin create minivend
#
# For mysql to work you would do: mysqladmin create minivend
#

EraseValue ProductFiles
ProductFiles component

Database component component SQL
Database component DSN dbi:Pg:dbname=cextest
Database component NUMERIC id,catid,upcatid
---------------------------------------------------------------------

MiniVend patch:
---------------------------------------------------------------------
diff -u -r1.1.1.2 -r1.2
--- lib/Vend/Data.pm    1999/08/09 19:40:19     1.1.1.2
+++ lib/Vend/Data.pm    1999/08/13 10:30:46     1.2
@@ -371,9 +371,13 @@
        my($type, $internal_query, $query, $msql, $table, $list) = @_;
        my ($db);
-       $table = 'products' unless defined $table;
-       $db = $Vend::Database{$table}
-               or die "dbi_query: unknown base table $table.\n";
+       if (defined $table) {
+         $db = $Vend::Database{$table}
+         or die "dbi_query: unknown base table $table.\n";
+       } else {
+         # use (first) product database as default
+         $db = $Vend::Productbase[0];
+       }
        $db = $db->ref();
        $type = lc $type;
---------------------------------------------------------------------

Bye 
		Racke


Search for: Match: Format: Sort by: