• Модуль: support
  • Путь к файлу: ~/bitrix/modules/support/classes/general/search.php
  • Класс: CSupportSearch
  • Вызов: CSupportSearch::getSql
static function getSql($query)
{
	if (!static::isIndexExists() || !static::CheckModule())
	{
		return false;
	}

	global $DB;

	$whereIn = '';
	$having = '';

	$words = array_keys(stemming($query, LANGUAGE_ID));

	if (count($words))
	{
		$whereInAll = array();

		foreach ($words as $word)
		{
			$whereInAll[] = "'".$DB->ForSql($word)."'";
		}

		$whereIn = 'TS.SEARCH_WORD IN ('.join(', ', $whereInAll).')';

		if (count($words) > 1)
		{
			$having = 'SUM(CASE WHEN '.$whereIn.' THEN 1 ELSE 0 END) = '.count($words);
		}
	}

	return array('WHERE' => $whereIn, 'HAVING' => $having);
}