Closed (fixed)
Project:
Search Autocomplete
Version:
6.x-2.1
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Jan 2012 at 10:44 UTC
Updated:
24 Jan 2012 at 20:50 UTC
In the function search_autocomplete_autocomplete you build the query with sprintf() and pass it through db_query(). Everthings fine as long als the suggestion query and the search keyword don't build a new %-modifier.
For example:
Query: "SELECT .... n.title LIKE '%%%s%%'"
Keyword: batman
After sprintf it looks like this: "SELECT .... n.title LIKE '%batman%'"
In phpmyadmin everythings fine but db_query tries to replace '%b' with a binary and the query don't return any suggestion. To fix this, just replace:
$suggestions = db_query($query);
with:
$suggestions = db_query($item['sug_query'], $word);
Comments
Comment #1
dom. commentedHi!
Sorry I did not reply ealier, I was in holiday! I will be back home by tomorrow and have a look at it.
Since the beginning, I was unhappy with the numerous %%% in the query string. Therefore, I will make a reliease with your change.
Even maybe better, I would like to avoid the %%% (and the %-modifier issue I did not though about). To do so, I will probably change the query with something like:
SELECT ... LIKE #As the symbol # should not be use in DB query, I will be able to change
#by
"%" . $word . "%"without using any sprintf like function.
Miro
Comment #2
dom. commentedPorted in 6.x-2.2
Thanks a lot for reporting and for fix suggestion !
Miro