...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integrity/entity/duplicateentitymatchhash.php
- Класс: Bitrix\Crm\Integrity\Entity\DuplicateEntityMatchHashTable
- Вызов: DuplicateEntityMatchHashTable::buildSqlConditions
static function buildSqlConditions(array $filter): array { $conditions = []; $connection = Main\Application::getConnection(); $sqlHelper = $connection->getSqlHelper(); $entityID = isset($filter['ENTITY_ID']) ? (int)$filter['ENTITY_ID'] : 0; if($entityID > 0) { $conditions[] = "ENTITY_ID = {$entityID}"; } $entityTypeID = isset($filter['ENTITY_TYPE_ID']) ? (int)$filter['ENTITY_TYPE_ID'] : \CCrmOwnerType::Undefined; if($entityTypeID > 0) { $conditions[] = "ENTITY_TYPE_ID = {$entityTypeID}"; } if(isset($filter['TYPE_ID'])) { if(is_array($filter['TYPE_ID'])) { if(!empty($filter['TYPE_ID'])) { $typeIds = ''; $i = 0; foreach ($filter['TYPE_ID'] as $value) { if($value > 0) $typeIds .= ($i++ === 0 ? '' : ',').(int)$value; } if(!empty($typeIds)) { $typeIds = 'TYPE_ID IN ('.$typeIds.')'; $conditions[] = $typeIds; } unset($typeIds); } } else { $typeID = (int)$filter['TYPE_ID']; if($typeID > 0) { $conditions[] = "TYPE_ID = {$typeID}"; } } } if(isset($filter['SCOPE'])) { if (is_array($filter['SCOPE'])) { if (!empty($filter['SCOPE'])) { $scopes = ''; $i = 0; foreach ($filter['SCOPE'] as $value) { $value = strval($value); if(!empty($value)) $scopes .= ($i++ === 0 ? '' : ',')."'".$sqlHelper->forSql($value)."'"; } if(!empty($scopes)) { $scopes = 'SCOPE IN ('.$scopes.')'; $conditions[] = $scopes; } unset($scopes); } } else { $scope = $sqlHelper->forSql($filter['SCOPE'], 6); $conditions[] = "SCOPE = '{$scope}'"; } } return $conditions; }