• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/filterquery.php
  • Класс: CFilterQuery
  • Вызов: CFilterQuery::BuildWhereClause
public function BuildWhereClause($word)
{
	$this->cnt++;
	//if($this->cnt>10) return "1=1";

	global $DB;
	if (isset($this->m_kav[$word]))
		$word = $this->m_kav[$word];

	$this->m_words[] = $word;

	$n = count($this->m_fields);
	$ret = "";
	if ($n>1) $ret = "(";
	for ($i=0; $i<$n; $i++)
	{
		$field = $this->m_fields[$i];
		if ($this->procent=="Y")
		{
			$ret.= "
				(upper($field) like upper('%".$DB->ForSqlLike($word, 2000)."%') and $field is not null)
				";
		}
		elseif (strpos($word, "%") !== false || strpos($word, "_") !== false)
		{
			$ret.= "
				(upper($field) like upper('".$DB->ForSqlLike($word, 2000)."') and $field is not null)
				";
		}
		else
		{
			$ret.= "
				($field='".$DB->ForSql($word, 2000)."' and $field is not null)
				";

		}
		if ($i<>$n-1) $ret.= " OR ";
	}
	if ($n>1) $ret.= ")";
	return $ret;
}