News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Improve search results

Started by Looking, August 30, 2015, 09:03:24 PM

Previous topic - Next topic

Looking

Greets, I want to search for the presence of a specific word from a custom field and display all topics that have it.

In the following I have a column called, "description" in the topics table. I have a specific word to search for using the variable "$directory". Below is what I am using but the results are not as good.

$request = $smcFunc['db_query']('', '
SELECT m.subject, m.id_topic, t.num_views, t.num_replies, t.description
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
WHERE t.description = {raw:match_topics} {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}' : '')  . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND b.id_board != {int:recycle_enable}' : '') . '
ORDER BY m.subject ASC
',
array(
'is_approved' => 1,
'recycle_enable' => $modSettings['recycle_board'],
'match_topics' => 't.description LIKE ' . implode(' OR t.description = ', $directory),

)
);


Please any recommendations to narrow the search?

Looking

Not in the way I wanted to do it but had to make a condition after the search, so this is solved.

Advertisement: