• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/volume/event.php
  • Класс: Bitrix\Crm\Volume\Event
  • Вызов: Event::countEntity
public function countEntity()
{
	$count = -1;

	if (count($this->getFilter()) > 0)
	{
		$query = $this->prepareQuery();
		$countField = new ORM\Fields\ExpressionField('CNT', 'COUNT(DISTINCT %s)', 'EVENT_ID');
	}
	else
	{
		//$query = Crm\EventTable::query();
		$query = $this->prepareNonRelationQuery();
		$countField = new ORM\Fields\ExpressionField('CNT', 'COUNT(%s)', 'EVENT_ID');
	}

	if ($this->prepareFilter($query))
	{
		$count = 0;

		$query->registerRuntimeField($countField);
		$query->addSelect('CNT');

		$res = $query->exec();
		if ($row = $res->fetch())
		{
			$count = $row['CNT'];
			$this->eventCount = $row['CNT'];
		}
	}

	return $count;
}