- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integration/catalog/contractor/agentcontractcontractortable.php
- Класс: Bitrix\Crm\Integration\Catalog\Contractor\AgentContractContractorTable
- Вызов: AgentContractContractorTable::bindToDocuments
static function bindToDocuments(int $entityTypeId, int $entityId, array $documentIds): void
{
if (empty($documentIds))
{
return;
}
$sqlHelper = Application::getConnection()->getSqlHelper();
$sqlValues = [];
foreach ($documentIds as $documentId)
{
$sqlValues[] = sprintf(
'(
%d,
%d,
%d
)',
$sqlHelper->convertToDbInteger($entityTypeId),
$sqlHelper->convertToDbInteger($entityId),
$sqlHelper->convertToDbInteger($documentId)
);
}
Application::getConnection()->query(sprintf(
'INSERT INTO %s (
ENTITY_TYPE_ID,
ENTITY_ID,
CONTRACT_ID
) VALUES %s
ON DUPLICATE KEY UPDATE ID = ID',
self::getTableName(),
implode(', ', $sqlValues)
));
}