in reply to Re: Best way to deal with quotes in string with DBI
in thread Best way to deal with quotes in string with DBI
Keep in mind in this case that you cannot delete nor add any keys into the hash between the keys %hash and values %hash! If you can't guarantee that you'd rather do something like:
my @keys = keys %hash; my $stmt = qq/INSERT INTO books ( / . join(',', @keys) . qq/) VALUES (/ . join(',', ('?') x @keys) . qq/)/; my $sth = $dbh->prepare($stmt); #... $sth->execute(@hash{@keys});
|
|---|