You'll want the keys of the hash to be the names of the colums you want to insert############ # Update the database # @param1: the table to be updated # @param2: the hash containing the data to be inserted into the databa +se # returns 1 if succesfull ############ sub updateDB { my $table = shift; my ($hashref) = @_; my (%hash) = %$hashref; my @fields; @fields = keys %hash; my $fields = join(', ', @fields); my $values = join(', ', map { $dbh->quote($_) } @hash{@fields}); my $sql = "INSERT into $table ($fields) values ($values)"; my $sth = $dbh->prepare($sql); $sth->execute(); $sth->finish(); return 1; }
In reply to Re: using databases
by Seqi
in thread using databases
by Bass-Fighter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |