• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicaterequisitecriterion.php
  • Класс: Bitrix\Crm\Integrity\DuplicateRequisiteCriterion
  • Вызов: DuplicateRequisiteCriterion::loadEntityMatches
static function loadEntityMatches($entityTypeID, $entityID, $countryId, $fieldName)
{
	if(!is_int($countryId))
	{
		throw new Main\ArgumentTypeException('countryId', 'integer');
	}

	if(!is_string($fieldName))
	{
		throw new Main\ArgumentTypeException('fieldName', 'string');
	}

	$query = new Main\Entity\Query(DuplicateRequisiteMatchCodeTable::getEntity());
	$query->addFilter('=ENTITY_TYPE_ID', $entityTypeID);
	$query->addFilter('=ENTITY_ID', $entityID);
	if ($countryId > 0)
		$query->addFilter('=RQ_COUNTRY_ID', $countryId);
	$query->addFilter('=RQ_FIELD_NAME', $fieldName);

	$query->addSelect('VALUE');
	$query->addSelect('RQ_COUNTRY_ID');

	$dbResult = $query->exec();
	$results = array();
	while($fields = $dbResult->fetch())
	{
		$results[] = array(
			'RQ_COUNTRY_ID' => $fields['RQ_COUNTRY_ID'],
			'RQ_FIELD_NAME' => $fieldName,
			'VALUE' => isset($fields['VALUE']) ? $fields['VALUE'] : ''
		);
	}
	return $results;
}