- or download this
my $cmd = "INSERT INTO $table ($fields) VALUES ($placeholderList)";
- or download this
# Accepts a database handle, a table name, and a hashref
# of field names and values. Returns on success, otherwise
...
sub addData
{
my ( $dbh, $table, $args ) = @_;
- or download this
# Get a comma separated list of the field names ..
my $fields = join(',', keys %$args);
...
# Get a comma separated list of '?', one for each value
# ..
my $placeholderList = join(',',('?') x @values);
- or download this
# Prepare the command and execute it with the array of
# values.
...
$sth->execute(@values) or die $sth->error;
return 0; # Success!
- or download this
# Accepts a database handle, a table name, and a hashref
# of field names and values. Returns on success, otherwise
...
return 0; # Success!
}