Batch Update Threads: How do I search for keyword not *keyword*

Chromaniac

Well-known member
I am trying to search for threads with just uber in title. But the search results are inclusive of words like Sauber and uberTwitter.

Is there a way to restrict the search to exact keyword? I imagine modifying the core XenForo code would not be a good idea.

Thanks!
 
Unfortunately, there is only a wildcard search available, so a code edit would be necessary - they are usually best avoided, but in this case as long as you make the change, do what you need to do, and then put the code back again, it shouldn't be a problem. You may even want to close the board temporarily as the particular code may be shared across other functions and therefore you don't want to necessarily affect the behaviour of those other functions.

Open file library/XenForo/Model/Thread.php

Find:
PHP:
$sqlConditions[] = 'thread.title LIKE ' . XenForo_Db::quoteLike($conditions['title'], 'lr', $db);
Replace:
PHP:
$sqlConditions[] = 'thread.title LIKE ' . XenForo_Db::quoteLike($conditions['title'], '', $db);

Once you're finished:

Find:
PHP:
$sqlConditions[] = 'thread.title LIKE ' . XenForo_Db::quoteLike($conditions['title'], '', $db);
Replace:
PHP:
$sqlConditions[] = 'thread.title LIKE ' . XenForo_Db::quoteLike($conditions['title'], 'lr', $db);
 
Incidentally, the 'lr' in the original code translates to 'left/right' or, in terms of the wildcard, it would be '*keyword*'.

'l' would be '*keyword'
'r' would be 'keyword*'
'' (as in the example above) would be 'keyword'
 
Top Bottom