79498336

Date: 2025-03-10 14:48:41
Score: 1.5
Natty:
Report link

To use an array in the WHERE clause, IN (), you need to create as many "?" as there are items in the array. A simple foreach or for loop before the SELECT clause will do. In the loop, for each item in the array, you will add "?" to a string $numberOfItems. So, if there are 4 items in the array, the string will look like this: ?, ?, ?, ?

In place of WHERE code IN (?), it will be WHERE code IN ($numberOfItems), which is equivalent to WHERE code IN (?, ?, ?, ?).

Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: yellow_melro