- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/internals/object.php
- Класс: BitrixDiskInternalsObjectTable
- Вызов: ObjectTable::updateAttributesByFilter
static function updateAttributesByFilter(array $attributes, array $filter)
{
$entity = static::getEntity();
$result = new Result();
$event = new EntityEvent($entity, self::EVENT_ON_BEFORE_UPDATE_ATTR_BY_FILTER, array(
'fields' => $attributes,
'filter' => $filter
));
$event->send();
$event->getErrors($result);
$attributes = $event->mergeFields($attributes);
//static::checkFields($result, null, $attributes);
if(!$result->isSuccess(true))
{
return $result;
}
$event = new EntityEvent($entity, self::EVENT_ON_UPDATE_ATTR_BY_FILTER, array(
'fields' => $attributes,
'filter' => $filter
));
$event->send();
$connection = MainApplication::getConnection();
$helper = $connection->getSqlHelper();
$tableName = static::getEntity()->getDBTableName();
$update = $helper->prepareUpdate($tableName, $attributes);
$filterAttributes = array();
foreach ($filter as $k => $v)
{
$filterAttributes[] = $helper->prepareAssignment($tableName, $k, $v);
}
$where = implode(' AND ', $filterAttributes);
$sql = "UPDATE ".$tableName." SET ".$update[0]." WHERE ".$where;
$connection->queryExecute($sql, $update[1]);
$event = new EntityEvent($entity, self::EVENT_ON_AFTER_UPDATE_ATTR_BY_FILTER, array(
'fields' => $attributes,
'filter' => $filter
));
$event->send();
return $result;
}