WorkflowInstanceTable :: mergeByDocument: Bitrix method

      
<?php 
//  Bitrix\Bizproc\Workflow\Entity\WorkflowInstanceTable :: mergeByDocument()
//  /dist/bitrix/modules/bizproc/lib/workflow/entity/workflowinstance.php:123

    
public static function mergeByDocument($paramFirstDocumentId$paramSecondDocumentId)
    {
        
$firstDocumentId = \CBPHelper::parseDocumentId($paramFirstDocumentId);
        
$secondDocumentId = \CBPHelper::parseDocumentId($paramSecondDocumentId);

        
$connection Main\Application::getConnection();
        
$sqlHelper $connection->getSqlHelper();
        
$table $sqlHelper->forSql(static::getTableName());

        
$firstDocId $sqlHelper->forSql($firstDocumentId[2]);
        
$firstEntity $sqlHelper->forSql($firstDocumentId[1]);
        
$firstModule $sqlHelper->forSql($firstDocumentId[0]);

        
$secondDocId $sqlHelper->forSql($secondDocumentId[2]);
        
$secondEntity $sqlHelper->forSql($secondDocumentId[1]);
        
$secondModule $sqlHelper->forSql($secondDocumentId[0]);

        
$connection->queryExecute("UPDATE {$table} 
            SET 
                DOCUMENT_ID = '
{$firstDocId}',
                ENTITY = '
{$firstEntity}',
                MODULE_ID = '
{$firstModule}
            WHERE 
                DOCUMENT_ID = '
{$secondDocId}
                AND ENTITY = '
{$secondEntity}
                AND MODULE_ID = '
{$secondModule}'
        "
);

        return 
true;
    }