- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/internals/attachedviewtype.php
- Класс: BitrixDiskInternalsAttachedViewTypeTable
- Вызов: AttachedViewTypeTable::set
static function set(array $params = [])
{
$entityType = (!empty($params['ENTITY_TYPE']) ? $params['ENTITY_TYPE'] : '');
$entityId = (!empty($params['ENTITY_ID']) ? intval($params['ENTITY_ID']) : 0);
$value = (isset($params['VALUE']) ? $params['VALUE'] : '');
if (empty($entityType))
{
throw new MainSystemException("Empty ENTITY_TYPE.");
}
if ($entityId <= 0)
{
throw new MainSystemException("Empty ENTITY_ID.");
}
if ($value == '')
{
throw new MainSystemException("Empty VALUE.");
}
$connection = MainApplication::getConnection();
$helper = $connection->getSqlHelper();
$insertFields = [
'ENTITY_TYPE' => $helper->forSql($entityType),
'ENTITY_ID' => $entityId,
'VALUE' => $helper->forSql($value),
];
$updateFields = [
'VALUE' => $helper->forSql($value),
];
$merge = $helper->prepareMerge(
static::getTableName(),
[ 'ENTITY_TYPE', 'ENTITY_ID' ],
$insertFields,
$updateFields
);
if ($merge[0] != '')
{
$connection->query($merge[0]);
}
}