Google Groups Home
Help | Sign in
Message from discussion Find by LIKE in 1.6
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Joel  
View profile
 More options Dec 30 2005, 8:55 pm
From: "Joel" <joel...@gmail.com>
Date: Fri, 30 Dec 2005 17:55:06 -0800
Local: Fri, Dec 30 2005 8:55 pm
Subject: Re: Find by LIKE in 1.6
Hi 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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google