• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/orm/query/query.php
  • Класс: Bitrix\Main\ORM\Query\Query
  • Вызов: Query::divideFilterHandler
protected function divideFilterHandler()
{
	$logic = $this->filterHandler->logic();

	if ($logic == 'or')
	{
		// if has aggr then move all to having
		if ($this->checkFilterHandlerAggregation($this->filterHandler))
		{
			$this->havingHandler = $this->filterHandler;
			$this->having_chains = $this->filter_chains;
		}
		else
		{
			$this->whereHandler = $this->filterHandler;
			$this->where_chains = $this->filter_chains;
		}
	}
	elseif ($logic == 'and')
	{
		// we can separate root filters
		foreach ($this->filterHandler->getConditions() as $condition)
		{
			$tmpFilter = static::filter()->addCondition($condition);

			if ($this->checkFilterHandlerAggregation($tmpFilter))
			{
				$this->havingHandler->addCondition($tmpFilter);
				$this->setFilterHandlerChains($tmpFilter, 'having');
			}
			else
			{
				$this->whereHandler->addCondition($condition);
				$this->setFilterHandlerChains($tmpFilter, 'where');
			}
		}
	}

	// collect "build_from" fields from having
	foreach ($this->having_chains as $chain)
	{
		if ($chain->getLastElement()->getValue() instanceof ExpressionField)
		{
			$this->collectExprChains($chain, array('hidden', 'having_expr'));
		}
	}
}