Обновляет highload-блок
@param $hlblockId
@param $fields
@return mixed
@throws \Sprint\Migration\Exceptions\HelperException
551020
public function updateHlblock($hlblockId, $fields) {
        $lang = array();
        if (isset($fields['LANG'])) {
            $lang = $fields['LANG'];
            unset($fields['LANG']);
        }

        $result = HL\HighloadBlockTable::update($hlblockId, $fields);
        if ($result->isSuccess()) {
            $this->replaceHblockLangs($hlblockId, $lang);
            return $hlblockId;
        }

        $this->throwException(__METHOD__, implode(', ', $result->getErrors()));
    }
588038
public function revertEntityId($entityId) {
        if (0 === strpos($entityId, 'HLBLOCK_')) {
            $hlblockName = substr($entityId, 8);
            $hlhelper = new HlblockHelper();
            $hlblock = $hlhelper->getHlblock($hlblockName);
            if (empty($hlblock)) {
                $this->throwException(__METHOD__, '%s not found', $entityId);
            }

            $entityId = 'HLBLOCK_' . $hlblock['ID'];
        }

        return $entityId;
    }
593556
private function executeInLock($lockName, callable $callback)
    {
        $this->res->getManagementLock()->lock($lockName);

        try {
            return call_user_func($callback);
        } finally {
            $this->res->getManagementLock()->unlock($lockName);
        }
    }
413748
public function update($id, $fields)
    {
        $fields = $this->makeJsonReady($fields);
        return $this->put('users/users/'.rawurlencode($id), $fields);
    }
983191
public function update(array $fields = [])
    {
        $connection = $this->getConnection();

        $this->beforeUpdateInternal();

        $connection->beginTransaction();
        try {
            if ($updated = $this->updateInternal($fields)) {
                $connection->commit();
            } else {
                $connection->rollBack();
            }
        } catch (Exception $e) {
            $connection->rollBack();
            throw $e;
        }

        $this->afterUpdateInternal();

        if ($updated) {
            $this->updateRelated();
            $this->attributes->resetOldAttributes();
        }

        return $updated;
    }
1230088
public function lock($lockType, $nonBlockingLock = false)
    {
        if ($nonBlockingLock) {
            return flock($this->_fileHandle, $lockType | LOCK_NB);
        } else {
            return flock($this->_fileHandle, $lockType);
        }
    }
1355099
function RowLock($tables,$where,$col='top 1 null as ignore')
	{
		if (!$this->_hastrans) $this->BeginTrans();
		$tables = str_replace(',',' HOLDLOCK,',$tables);
		return $this->GetOne("select $col from $tables HOLDLOCK where $where");

	}
409253
public function getHlblockIdIfExists($hlblockName) {
        $item = $this->getHlblock($hlblockName);
        if ($item && isset($item['ID'])) {
            return $item['ID'];
        }

        $this->throwException(__METHOD__, "hlblock id not found");
    }
603683
public function update($fields)
    {
        // Set fields
        $this->fields($fields);

        // Resolve fields
        $fields = $this->getUpdateFieldsString();

        // Define wheres
        $where = $this->getWhereString();

        // Build query
        $this->query = 'UPDATE ' . $this->table . ' SET ' . $fields . ' '. $where;

        // Prepare statement
        $this->statement = $this->pdo->prepare($this->query);

        // Bind fields values
        $this->bindFields();

        // Bind where values
        if (count($this->wheres)) {
            $this->bindWheres();
        }

        // Execute statement
        $result = $this->statement->execute();

        // Reset values
        $this->reset();

        // Return result
        return $result;
    }
300038
public static function getLock($id) {

        $model = get_called_class();
        /* @var $t Record */
        $t = new $model;
        $select = DB::select($t->getTable())->where($t->getPkField(), $id)->lock()->setRecord($model);
        Event::trigger('record_before_select', [$t, $select]);
        $data = $select->find();
        return $data;
    }
599390
public function hincrby($key, $field, $increment = 1)
    {
        $this->init();
        return $this->driver->hincrby($key, $field, (int)$increment);
    }
597220
public function sharedLock()
    {
        // Pack query then move it to write DB from read DB for transaction
        $sql = $this->_dbr->get_compiled_select();
        $this->_dbr->reset_query();

        return $this->_db->query("{$sql} LOCK IN SHARE MODE");
    }
814382
public function addHlblock($fields) {
        $this->checkRequiredKeys(__METHOD__, $fields, array('NAME', 'TABLE_NAME'));

        $lang = array();
        if (isset($fields['LANG'])) {
            $lang = $fields['LANG'];
            unset($fields['LANG']);
        }

        $fields['NAME'] = ucfirst($fields['NAME']);

        $result = HL\HighloadBlockTable::add($fields);
        if ($result->isSuccess()) {
            $this->replaceHblockLangs($result->getId(), $lang);
            return $result->getId();
        }

        $this->throwException(__METHOD__, implode(', ', $result->getErrors()));
    }
1169012
public function setUserTypeHL($table_name, $showField)
    {
        $linkId = Helpers::getHlId($table_name);
        $this->setUserType('hlblock')->setSettings([
            'HLBLOCK_ID' => Helpers::getHlId($table_name),
            'HLFIELD_ID' => Helpers::getFieldId(Constructor::objHLBlock($linkId), static::prepareUf($showField)),
        ]);

        return $this;
    }
398570
public function doLock($blocking = false)
    {
        if ($this->lockAcquired) {
            return $this;
        }

        $this->mode   = $this->mode ?: (is_file($this->file) ? 'rb' : 'wb');
        $this->handle = fopen($this->file, $this->mode) ?: null;
        if (
            $this->lockType === self::LOCK_EXTERNAL &&
            $this->mode === 'wb' &&
            !$this->handle
        ) {
            // if another process won the race at creating lock file
            $this->mode   = 'rb';
            $this->handle = fopen($this->file, $this->mode) ?: null;
        }

        $this->lockAcquired = $this->handle ? flock($this->handle, $blocking ? LOCK_EX : LOCK_EX | LOCK_NB) : false;

        if (!$this->lockAcquired) {
            $this->unLock();
        }

        return $this;
    }
1037040
public function exportFields($hlblockName) {
        $fields = $this->getFields($hlblockName);
        $export = array();
        foreach ($fields as $field) {
            $export[] = $this->prepareExportHlblockField($field);
        }

        return $export;
    }
1292730
public static function getHlId($table_name)
    {
        if (!isset(static::$hls[$table_name])) {
            $dbRes = Application::getConnection()->query('SELECT `ID`, `NAME`, `TABLE_NAME` FROM b_hlblock_entity');
            while ($block = $dbRes->fetch()) {
                static::$hls[$block['TABLE_NAME']] = $block;
            }
        }

        return static::$hls[$table_name]['ID'];
    }