I have a problem with PDO that I really would like to get an answer for having tormented you for so long.
Take this example:
I am associating an ID array with a PDO statement for use in a MySQL IN statement.
The array will say: $ values = array (1,2,3,4,5,6,7,8);
The database safe variable will be $ products = implode (',' $ values);
So $ products will then be STRING with the value: '1,2,3,4,5,6,7,8'
The operation will look like this:
SELECT users.id FROM users JOIN products ON products.user_id = users.id WHERE products IN (:products)
Of course, $ products will be tied to an expression like : products .
However, when the operator compiles and values are bound, it will look something like this:
SELECT users.id FROM users JOIN products ON products.user_id = users.id WHERE products IN ('1,2,3,4,5,6,7,8')
The problem is that it executes everything inside the IN statement as a single line, given that I prepared it as comma-separated values for binding to the instruction.
I really need:
SELECT users.id FROM users JOIN products ON products.user_id = users.id WHERE products IN (1,2,3,4,5,6,7,8)
The only way I can really do this is to put the values inside the string itself without linking them, however I know that there must be an easier way to do this for this.