• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/timeline/entity/timelinebinding.php
  • Класс: Bitrix\Crm\Timeline\Entity\TimelineBindingTable
  • Вызов: TimelineBindingTable::upsert
static function upsert(array $data)
    {
	$ownerID = isset($data['OWNER_ID']) ? (int)$data['OWNER_ID'] : 0;
	if($ownerID <= 0)
	{
		throw new Main\ArgumentException('The OWNER_ID field must be assigned and must be greater than zero.', 'data');
	}

	$entityTypeID = isset($data['ENTITY_TYPE_ID']) ? (int)$data['ENTITY_TYPE_ID'] : 0;
	if($entityTypeID <= 0)
	{
		throw new Main\ArgumentException('The ENTITY_TYPE_ID field must be assigned and must be greater than zero.', 'data');
	}

	$entityID = isset($data['ENTITY_ID']) ? (int)$data['ENTITY_ID'] : 0;
	if($entityID <= 0)
	{
		throw new Main\ArgumentException('The ENTITY_ID field must be assigned and must be greater than zero.', 'data');
	}

	$fields = array(
		'OWNER_ID' => $ownerID,
		'ENTITY_TYPE_ID' => $entityTypeID,
		'ENTITY_ID' => $entityID
	);

	if (isset($data['IS_FIXED']))
	{
		$fields['IS_FIXED'] = $data['IS_FIXED'];
	}

	$connection = Main\Application::getConnection();
	$queries = $connection->getSqlHelper()->prepareMerge(
		'b_crm_timeline_bind',
		array('OWNER_ID', 'ENTITY_TYPE_ID', 'ENTITY_ID'),
		$fields,
		$fields
	);

	foreach($queries as $query)
	{
		$connection->queryExecute($query);
	}
}