Which of these equivalents is preferable:
$medium_csv = implode(",",$medium_array);
mysql_query('SELECT col1, col2 FROM table1 WHERE user_id IN ($medium_csv)');
or this:
foreach ($medium_array as $array_item) {
mysql_query('SELECT col1, col2 FROM table1 WHERE user_id = $array_item');
}
*The array is between 10 and 500 items if that matters
Making between 10 and 500 calls to MySQL is unnecessary, when you have the option to settle with one call. It’s as simple as that.