CCrmActivity::DoSaveElementIDs

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmActivity
  4. DoSaveElementIDs
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/mysql/crm_activity.php
  • Класс: \CCrmActivity
  • Вызов: CCrmActivity::DoSaveElementIDs
static function DoSaveElementIDs($ID, $storageTypeID, $arElementIDs)
{
	global $DB;

	$ID = intval($ID);
	$storageTypeID = intval($storageTypeID);
	if($ID <= 0 || !CCrmActivityStorageType::IsDefined($storageTypeID) || !is_array($arElementIDs))
	{
		self::RegisterError(array('text' => 'Invalid arguments are supplied.'));
		return false;
	}

	$DB->Query(
		'DELETE FROM '.self::ELEMENT_TABLE_NAME.' WHERE ACTIVITY_ID = '.$ID,
		false,
		'File: '.__FILE__.'
Line: '.__LINE__ ); if(empty($arElementIDs)) { return true; } $arRows = array(); foreach($arElementIDs as $elementID) { $arRows[] = array( 'ACTIVITY_ID'=> $ID, 'STORAGE_TYPE_ID' => $storageTypeID, 'ELEMENT_ID' => $elementID ); } $bulkColumns = ''; $bulkValues = array(); foreach($arRows as &$row) { $data = $DB->PrepareInsert(self::ELEMENT_TABLE_NAME, $row); if($bulkColumns === '') { $bulkColumns = $data[0]; } $bulkValues[] = $data[1]; } unset($row); $query = ''; foreach($bulkValues as &$value) { $query .= ($query !== '' ? ',' : '').'('.$value.')'; } if($query !== '') { $sql = 'INSERT INTO '.self::ELEMENT_TABLE_NAME.'('.$bulkColumns.') VALUES '.$query.' ON DUPLICATE KEY UPDATE ELEMENT_ID = ELEMENT_ID, STORAGE_TYPE_ID = STORAGE_TYPE_ID, ACTIVITY_ID = ACTIVITY_ID'; $DB->Query($sql, false, 'File: '.__FILE__.'
Line: '.__LINE__); } return true; }

Добавить комментарий