How to pass in the query preparedstatement to mysql array values in IN()?

Example query: SELECT users FROM table WHERE id IN(?)
Googling found a discussion of the problem
from which it becomes clear that without crutches just because the array is not substitute.
The answers are dated 2-3 years ago, maybe at the moment there is a solution.?
Or is only to generate a preparedstatement with the necessary number IN(?,?,?....) for each request?
July 9th 19 at 13:07
2 answers
July 9th 19 at 13:09
Everything is so well done.
And this is done only in a few lines.

$bind = ['somebind'];
$places = implode(', ', array_fill(0, count($bind), '?'));
$sqlpartial = " where column IN ($places) ";
The author of the Java - Lonzo.Johnston commented on July 9th 19 at 13:12
: well, the answer does not change much, only code is not suitable)) I have a habit to thought PHP - bailee_Stant commented on July 9th 19 at 13:15
July 9th 19 at 13:11
If you are really so lazy to write a short function that will fill the PreparedStatement then use any library to work with SQL. Comes to my mind first and foremost JdbcTemplate from spring jdbc.
The problem is not that I broke, and how it will be optimized. As I understand it create a preparedstatement to speed up query execution with multiple calls. Whether to generate it each time under one request? Wouldn't it be faster to work a normal statement? - Lonzo.Johnston commented on July 9th 19 at 13:14
The usual statement will run faster, but these requests are less secure(you are responsible for security) and worse supported. Thus gaming performance you lose by other criteria.
If your case is IN the query each time is new, then you may want to look for other optimizations(e.g. temporary tables or stored procedures). - bailee_Stant commented on July 9th 19 at 13:17

Find more questions by tags JavaJDBCMySQLPrepared expressions