Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Comment on

To answer your question: $sth->statement will show you the statement exactly as it was prepared (with placeholders). Unfortunately, this won't help you much in this case, as has already been pointed out.

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).") ");

-- Time flies when you don't know what you're doing

In reply to Re: Is there a way to display the statement generated by DBD on execute() by FloydATC
in thread Is there a way to display the statement generated by DBD on execute() by Cody Fendant

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (9)
    As of 2014-12-26 18:07 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (174 votes), past polls