in reply to Using OR in SELECT statments safely
my @items_to_include = qw/1 11 45 73 27/; my $query = "SELECT * FROM catalog WHERE "; $query .= join " OR ", ("item_id=?") x @items_to_include; my $sth = $dbh->prepare($query); $sth->execute(@items_to_include);
It's not that ugly, IMHO.
$query is generated dynamically, and it is always a valid query. Also, there will always be the same number of question mark placeholders as bind variables. And it still has the upside that you get to use placeholders for the (I assume) untrusted data in @items_to_include.
blokhead
|
|---|