• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/internals/file.php
  • Класс: BitrixDiskInternalsFileTable
  • Вызов: FileTable::changeStorageId
static function changeStorageId($primary, $newStorageId)
{
	$newStorageId = (int)$newStorageId;
	// check primary
	static::normalizePrimary($primary);
	static::validatePrimary($primary);

	// save data
	$connection = Application::getConnection();
	$helper = $connection->getSqlHelper();

	$tableName = static::getEntity()->getDBTableName();
	$update = $helper->prepareUpdate($tableName, array('STORAGE_ID' => $newStorageId));

	$id = array();
	foreach ($primary as $k => $v)
	{
		$id[] = $helper->prepareAssignment($tableName, $k, $v);
	}
	$where = implode(' AND ', $id);

	$sql = "UPDATE ".$tableName." SET ".$update[0]." WHERE ".$where;
	$connection->queryExecute($sql, $update[1]);

	$result = new UpdateResult();
	$result->setAffectedRowsCount($connection);
	$result->setData(array('PARENT_ID' => $newStorageId));

	return $result;
}