in reply to
Re^2: DBI - Table names & placeholders
in thread DBI - Table names & placeholders
The bottom loop should be
for (@$sales_inserts) {
my $table = shift(@$_);
my $sth = $dbh->prepare('
INSERT INTO '.$dbh->quote_identifier($table).' (
ItemID, Day, Revenue, Count
) VALUES (
?, ?, ?, ?
)
');
$sth->execute(@$_);
}
or
my %sth_cache;
for (@$sales_inserts) {
my $table = shift(@$_);
my $sth = $sth_cache{$table} ||= $dbh->prepare('
INSERT INTO '.$dbh->quote_identifier($table).' (
ItemID, Day, Revenue, Count
) VALUES (
?, ?, ?, ?
)
');
$sth->execute(@$_);
}