Using %%%s%% with LIKE in a query allows one to filter for containment - so does views. However I noted troubles searching for something that starts with 'b', 'd', 's', .. (see http://api.drupal.org/api/function/_db_query_callback/6).

So usually %s is replaced with the search string, %% with % so the db server correctly gets %input%. However when %s gets replaced and input is 'boo' there is %%boo%% and then I think %b gets replaced erroneously.

Comments

fago’s picture

Title: using db_query to filter for containment » queries might break when filtering for containment

I filed an issue for views too: #670748: contained text filter breaks.

fago’s picture

Status: Active » Closed (fixed)

I was wrong with the assumption the problem is in db_query() - views 5.x-1.6 did the replacements twice. Luckily this means there is no bug in core.