Hello everyone,
assuming i want to write some values into my database of choice i found two ways to do this.
my $sql = "INSERT INTO table (foo, bar, foobar) VALUES (?, ?, ?)";
my $sth = $dbh->prepare($sql);
foreach(sort keys %hash)
{
$sth->execute($_, $hash{$_}, $some_other_value);
}
as opposed to this one:
foreach(sort keys %hash)
{
$dbh->do("INSERT INTO table (foo, bar, foobar) VALUES ('$_', '$hash{$_}', '$some_other_value')");
}
Speedwise they are both pretty much the same. My question is now:
Is one of them the "better" or "right" way to do it?