Parameterized Queries and Multiple Values

Posted by Sir Four at 4:47pm Aug 23 '09
You must sign in to send Sir Four a message
Implementations of parameterized queries generally do a one-for-one substitution, which makes sense when we're talking about something like 'WHERE column = ?', however this has posed a nagging problem for me when it comes to the IN condition. If you know in advance exactly how many values you intend to pass to the query, you can do something like 'WHERE column IN (?, ?, ?)' and bind the three values. But trouble arises when the number of values is arbitrary. I'd like to do 'WHERE column IN (?)' and pass an arbitrary-length array of values. Has JDBC provided such functionality? Is it available in PHP (PDO)?

added on 5:11pm Aug 23 '09:
Also, I don't care for stored procedures, though I know it's possible to work around this problem that way.
There are 10 private posts in this thread. You need to sign in to read them.

Below are the public posts you may view:

You currently have read-only access to this board. You must request an account to join the conversation.

Why Join 4thKingdom?

Note that there are no ads here. Just intelligent and friendly conversation. We keep the spam out, the trolls out, the advertisers out… 4K is just a low-key, old-fashioned site with members from around the world.
This community began in 1998, and we continue to accept new members today.

Hot Discussion Topics: