What happens when you do a SQL query where the IN
clause is empty?
For example:
SELECT user WHERE id IN ();
Will MySQL
If you use AUTO_INCREMENT for id (1,2,3, ..) and if array is empty, you can add one item [0]. So it will be
if (empty($arr)) {
$arr[] = 0;
}
SELECT user WHERE id IN (0);
And there will be no mysql parse error. This case is very usefull in subqueries - when your main query is not dependent on subquery results.
Better way - don't call the query if array is empty.
$data = null;
if (!empty($arr)) {
$data = ... call query
}