in reply to Is there a way to display the statement generated by DBD on execute()
If you must use a prepared statement to pass your list, you could consider using the MySQL FIND_IN_SET() function, which accepts the list join()'ed into a single string.
Another possible approach might be to use an SQL sub query to build the list, that way you never have to pass it in the first place:
SELECT foo FROM bar WHERE id IN ( SELECT id FROM baz WHERE a = b )
Finally, there are alternatives to using prepared statements, but you'll have to guard against injection attacks in some other way. In the case of a list of integer IDs this is ofcourse trivial.
my @integers = map { int } @list; my $sth->prepare(" SELECT foo FROM bar WHERE id IN (".join(',',@integers).") ");
|
|---|