[wp-hackers] Limiting get_users() results by meta value

Andrew Nacin wp at andrewnacin.com
Fri Feb 1 16:24:10 UTC 2013


On Fri, Feb 1, 2013 at 11:13 AM, Mike Walsh <mpwalsh8 at gmail.com> wrote:

> As you can see, the LIKE clause is escaped and wrapped with SQL wildcard
> operators.  I can't figure out how to prevent this from happening as what I
> want is "LIKE 'M%'" to be my actually query.  I can't seem to find what I
> am searching for when I Google it, can anyone point me to an example of how
> to do what I want to do?
>

Currently, "LIKE" prepends and appends wildcards, as in %term%. We could
add "%LIKE" and "LIKE%", though that would not help with the situation
where you want LIKE taken literally, potentially without % wildcards at
all. (Such as using _ as a single-character wildcard, or looking for case
insensitive matching.) Probably the best way to add to this API would be to
allow for a 'like_escape' => false; that would accept your value as
provided. If you'd like to submit a ticket (and patch), this can definitely
find its way into 3.6.

Nacin


More information about the wp-hackers mailing list