MiniVend Akopia Services

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

Re: Using a Form to Update a Database PLEASE HELP!



******    message to minivend-users from Frank Miedreich <miedreich@acm.org>     ******

>******    message to minivend-users from "William Rothbauer"
><madpages@madpages.com>     ******
>
>I'm really struggling with this one.  I'm trying to update a database from a
>form.  Whenever I try to do the update, minivend hits the database in
>question (updates the database date and time) but the data is never changed,
>deleted, inserted, etc.
>
>No errors are produced in the error log.  I am working with GDBM database
>files.  Any pointers would be greatly appreciated.
>
>Thanks,
>
>Bill
>

Here are some excerpts from what I use. Handle with care.

>From minivend.cfg a little GlobalSub which creates a new productid:

GlobalSub <<EOF
sub productid {
	$File::CounterFile::DEFAULT_DIR = $Vend::Cfg->{'VendRoot'};
	my $c = new File::CounterFile 'etc/product.counter', "000000";
	my $product_no = $c->inc;
	undef $c;
	return $product_no;
}
EOF

from a minivend generated page the part that creates a new product:

<FORM ACTION="[process-target content]" METHOD=POST>
<INPUT TYPE=hidden NAME=mv_todo VALUE=return>
<INPUT TYPE="hidden" NAME="mv_check" VALUE="update">

[set update]
[tag flag write]products[/tag]
[set name="code" interpolate=1][perl sub]productid()[/perl][/set]
[value name="code" set="[scratch code]"]
[data base="products" field="description" key="[value code]" value="[value
description]"]
[data base="products" field="price" key="[value code]" value="[value price]"]
[data base="products" field="name" key="[value code]" value="[value name]"]
[data base="products" field="category" key="[value code]" value="[value
category]"]
[data base="products" field="company" key="[value code]" value="[value
company]"]
[tag export products][/tag]
[/set]

<obvious form field go here>


To use the same thing to update an existing product, change the [value
code] thingies to [item-code] or something to that effect.

I have absolutely no idea why I use both a scratch variable and a value for
the product code. It has a deep mystical meaning I suppose. There are also
new database functions in minivend which I never got around including in
this catalog, but this might be something to look at, could be safer to
use. This would also include a delete function, you don't want to know how
I do this using the same method, and I am not going to tell you. (People
who think I am good at what I am doing are listening)

Are you sure the data is never changed in your solution? The updating of
the database will  not change the .asc on it's own, and you will usually
need the [tag flag write]. Maybe only the gdbm got changed?

Have fun, Frank



--
Frank Miedreich
Max-Planck-Institut fuer psychologische Forschung


-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: