• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/location/search/wordchain.php
  • Класс: BitrixSaleLocationSearchWordChainTable
  • Вызов: WordChainTable::search
static function search($words, $offset) // very temporal prototype
{
	$dbConnection = MainHttpApplication::getConnection();
	$dbHelper = MainHttpApplication::getConnection()->getSqlHelper();

	$where = array();

	foreach($words as $word)
	{
		$whereWord = array();
		for($k = 1; $k <= 10; $k++)
		{
			$whereWord[] = "W_".$k." like '".$dbHelper->forSql($word)."%'";
		}

		$where[] = '('.implode(' or ', $whereWord).')';
	}

	$sql = "
		select SQL_NO_CACHE IX.LOCATION_ID as ID, L.CODE, IX.TYPE_ID, L.LEFT_MARGIN, L.RIGHT_MARGIN, N.NAME as NAME from ".static::getTableName()." IX

			inner join b_sale_location L on IX.LOCATION_ID = L.ID
			inner join b_sale_loc_name N on IX.LOCATION_ID = N.LOCATION_ID and N.LANGUAGE_ID = 'ru'

			where ".implode(' and ', $where)."

		order by 
			IX.SORT asc,
			IX.TYPE_SORT asc
		limit 10
		".(intval($offset) ? 'offset '.intval($offset) : '')."
	";

	_dump_r($sql);

	/*
	print('
');
	print_r($sql);
	print('
'); */ return $dbConnection->query($sql); }