switch ($phrase)
{
case 'exact':
$text = $db->quote('%' . $db->escape($text, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'a.title = ' . $text;
/* $wheres2[] = 'a.introtext LIKE ' . $text;
$wheres2[] = 'a.fulltext LIKE ' . $text;
$wheres2[] = 'a.metakey LIKE ' . $text;
$wheres2[] = 'a.metadesc LIKE ' . $text; */
$where = '(' . implode(') OR (', $wheres2) . ')';
break;
case 'all':
case 'any':
default:
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word)
{
$word = $db->quote('%' . $db->escape($word, true) . '%', false);
$wheres2 = array();
$wheres2[] = 'LOWER(a.title) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.introtext) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.fulltext) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.metakey) LIKE LOWER(' . $word . ')';
$wheres2[] = 'LOWER(a.metadesc) LIKE LOWER(' . $word . ')';
$wheres[] = implode(' OR ', $wheres2);
}
$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
break;
}