Your release notes for 1.6 indicate that searching by LIKE has not
been implemented, but that there were workarounds. Well, it just so
happens that I need a LIKE search; can you help me out?
Cheers!
Aaron.
I assume that you're using base64 encode to store your data right?
If you're not (i.e you disabled the Escape and Unescape feature), you
can simply pass "LIKE" as the comparator and %partialstring% as the
value. This should return the correct value(s).
If your data is encoded in the database, then you will need to change
your object manually. I will send you a code example later today.
Hope this helps.
Joel
Cheers,
Aaron.
To get partial string matching to work with the GetList() function,
you'll need to create a Filter function (similar to the Compare
functions that allows pog to sort objects). It should look like this:
function FilterList($objectList, $attributeToCompare, $value)
{
$filteredList = array();
foreach ($objectList as $object)
{
if (strpos($object->{$attributeToCompare}, $value))
{
$filteredList[] = $object;
}
}
return $filteredList;
}
Then you can call this function whenever you need to filter your object
list as follows:
$objectList = $objectList->FilterList($objectList, $attributeName,
$value);
However, what this means is that you'll first need to get the entire
object list (or a sublist using another condition) and *then* filter
it. I would suggest coding to accommodate for POG in this scenario, i.e
if you absolutely need partial string matching, then use another
condition to shorten the list.
This is, as you see, not very efficient at all, and that's why we
didn't put it in 1.6. It would have penalized GetList() to accomodate
partial string matching. I don't think there's a way to improve this
drastically, unless base64 is supported natively by mysql or any other
database....
I encourage anyone who might have a better solution to let us know.
But I hope this *patch* helps you get the job done.
Let me know.
Joel