So we have a text entry for our model where the user enters a city.
We then have a search.
We want the user to be able to search for multiple cities
(e.g. comma separated list).
This code works fine for one city:
So then I went and tried this for the multiple match:
But it doesn't work - the search returns no elements as soon as we have a comma separated list of values.
Any ideas on how to resolve this?
Thank you
$model->city
We then have a search.
We want the user to be able to search for multiple cities
(e.g. comma separated list).
This code works fine for one city:
$criteria->compare('city',$this->city,true);
So then I went and tried this for the multiple match:
if ($this->city) { if (strpos($this->city,',') !==false) { $cities = explode(',',$this->city); foreach($cities as $c) { $criteria->compare('city',$c,true); //I also tried things like $criteria->compare('city',$c,true,"AND",true); } } else { $criteria->compare('city',$this->city,true); } }
But it doesn't work - the search returns no elements as soon as we have a comma separated list of values.
Any ideas on how to resolve this?
Thank you