Possible Duplicate:
PDO with “WHERE… IN” queries
In my search form, there is a lot of check boxes and fields.
Some checkboxes belong to the group.
Example group, city.
Query like the following
SELECT id, city_id, area, city FROM an_objects
WHERE livedays > 0 AND type_id = :typeoffer AND rubric_id = :typerelaty
AND CASE
WHEN :1r = '' THEN true
ELSE city_id IN (:1r, :2r, :99r, :100r)
END
GROUP BY id ORDER BY date ASC
In this example, the need to fill 4 parameters, or a hundred.
But I want to do
SELECT id, city_id, area, city FROM an_objects
WHERE livedays > 0 AND type_id = :typeoffer AND rubric_id = :typerelaty
AND CASE
WHEN :1r = '' THEN true
ELSE city_id IN (:arrCity)
END
GROUP BY id ORDER BY date ASC
String form the so
if(isset($param['city']))
{
for($i=0; $i < 9; $i++)
{
if(isset($param['city'][$i]))
$raion .= $param['city'][$i] . ",";
else
break;
}
$arrCity = substr($city, 0, -1);
}
We have the following
(: arrCity) substituted ("1,2,3,4,5,6").
This is obtained as a single string, but how to do the following
(: arrCity) (1,2,3,4,5,6)