I have a multi-value field in my DB, which stores the values in the following format: |1|2|3|4|
Notice the enclosing ‘|’ (pipe symbols) at the beginning and end of the string. This makes it possible for me to search for an exact value in that field, for example ‘11’ will not match, but ‘1’ will.
I now wish to perform a foreach loop on this field.
foreach(Subcategory::model()->findAll('parent_cats LIKE :parent_cats',
array(':parent_cats'=>'%|'.$category->id.'|%')) as $subcategory)
But this does not seem to work - I get error "Invalid argument supplied for foreach()".