Updates a table's record based on the query information provided in the $config variable.

@param array $config
@param string $operation Whether to increase or decrease a value. Valid values: +/-
@param int|float|double $amount
@param string $foreignKey
189962
public function updateCacheRecord(array $config, $operation, $amount, $foreignKey)
    {
        if (is_null($foreignKey)) {
            return;
        }

        $config = $this->processConfig($config);

        $sql = DB::table($config['table'])->where($config['key'], $foreignKey);

        /*
         * Increment for + operator
         */
        if ($operation == '+') {
            return $sql->increment($config['field'], $amount);
        }

        /*
         * Decrement for - operator
         */
        return $sql->decrement($config['field'], $amount);
    }
57680
public function detectForeignKey($config, $class) {
        $foreignKey = $this->getConfig($config);

        if (!$foreignKey) {
            $foreignKey = $this->buildForeignKey($class);

            $this->setConfig($config, $foreignKey);
        }

        return $foreignKey;
    }
371047
public function set($configOption, $configValue) {
        $this->repository->cmd(sprintf('config --local %s %s', $configOption, $configValue));
        unset($this->configuration[$configOption]);
    }
1296488
public function addForeignKey(ForeignKey $foreignKey)
    {
        $this->table = $this->table->withForeignKeys(
            array_merge($this->table->getForeignKeys(), [$foreignKey])
        );
    }
64519
private function doUpdates($config)
    {
        try {
            $this->addStatusToOrder($config->order_id, $config->pagseguro_status);
            $this->updateSalesOrder($config->order_id, $config->pagseguro_id);
            $this->updatePagSeguroOrders($config->order_id, $config->pagseguro_id);
            return true;
        } catch (\Exception $exception) {
            throw $exception;
        }
    }
56310
public function _performOperation($key, FieldOperation $operation)
    {
        $oldValue = null;
        if (isset($this->estimatedData[$key]))
        {
            $oldValue = $this->estimatedData[$key];
        }
        $newValue = $operation->_apply($oldValue, $this, $key);
        if ($newValue !== null)
        {
            $this->estimatedData[$key] = $newValue;
        } else if (isset($this->estimatedData[$key]))
        {
            unset($this->estimatedData[$key]);
        }

        if (isset($this->operationSet[$key]))
        {
            $oldOperations = $this->operationSet[$key];
            $newOperations = $operation->_mergeWithPrevious($oldOperations);
            $this->operationSet[$key] = $newOperations;
        } else
        {
            $this->operationSet[$key] = $operation;
        }
        $this->dataAvailability[$key] = true;
    }
300035
protected function applyExtraConfig($config, $field = null)
    {
        if (!$field) {
            $field = $this->field;
        }

        if (!$config || !isset($this->originalConfig->{$field})) {
            return;
        }

        if (
            !is_array($config) &&
            (!$config = @json_decode(@base64_decode($config), true))
        ) {
            return;
        }

        $parsedConfig = array_only($config, ['readOnly']);
        $parsedConfig['view'] = array_only($config, ['recordUrl', 'recordOnClick']);

        $this->originalConfig->{$field} = array_replace_recursive(
            $this->originalConfig->{$field},
            $parsedConfig
        );
    }
994363
public function increment($key, $val = 1, $field = null, $tablePrefix = null)
    {
        list($tableName, $condition) = $this->parseKey($key, true);
        if (is_null($field) || empty($tableName) || empty($condition)) {
            $this->clearBindParams();
            return false;
        }
        $val = abs(intval($val));
        is_null($tablePrefix) && $tablePrefix = $this->tablePrefix;
        $tableName = $tablePrefix . $tableName;

        $this->currentQueryIsMaster = true;
        $stmt = $this->prepare('UPDATE  `' . $tableName . "` SET  `{$field}` =  `{$field}` + {$val}  WHERE  $condition", $this->wlink);

        $this->execute($stmt);
        $this->setCacheVer($tableName);
        return $stmt->rowCount();
    }
218341
public function createForeignKey($foreignKey, $table)
    {
        $changeSetElt = $this->createChangeSet('create-foreign-keys-' . $table->getName());
        $addForeignKeyConstraintElt = $this->document->createElement('addForeignKeyConstraint');

        $this->fillForeignKeyAttributes($addForeignKeyConstraintElt, $foreignKey, $table);

        $changeSetElt->appendChild($addForeignKeyConstraintElt);
        $this->root->appendChild($changeSetElt);
    }
1245208
protected function applyBridgeCollectionConfig(array $config)
    {
        if (!isset($config['bridge']) || !is_string($config['bridge'])) {
            throw new UnexpectedValueException($this->translate(
                'Relation field configuration should contain bridge collection name and name should be a string.'
            ));
        }
        $this->bridgeCollectionName = $config['bridge'];
    }
1016845
protected function incrementOrDecrementAttributeValue($column, $amount, $extra, $method)
    {
        $this->{$column} = $this->{$column} + ($method === 'increment' ? $amount : $amount * -1);

        $this->forceFill($extra);

        $this->syncOriginalAttribute($column);
    }
1026437
protected function affectedRows($relation, $foreignKey, $foreignKeyIds)
    {
        $relationModel = $relation->getQuery()->getModel();
        $relationModel = new $relationModel();

        return $relationModel->withTrashed()->whereIn($foreignKey, $foreignKeyIds)->count();
    }
426268
protected function insertBelongsTo(Model $record, Relation $relation, $columnValue)
    {
        $foreignKeyName = $relation->getForeignKey();
        $foreignKeyValue = $this->generateKey($columnValue);
        $record->$foreignKeyName = $foreignKeyValue;
    }
119163
public function create( $model, $config = [] ) {

		$this->updateBase( $model );

		return parent::create( $model, $config );
	}
409071
public function Configure($Offset, $Limit, $TotalRecords, $Url, $ForceConfigure = FALSE) {
      if ($this->_PropertiesDefined === FALSE || $ForceConfigure === TRUE) {
         if (is_array($Url)) {
            if (count($Url) == 1)
               $this->UrlCallBack = array_pop($Url);
            else
               $this->UrlCallBack = $Url;
         } else {
            $this->Url = $Url;
         }

         $this->Offset = $Offset;         
         $this->Limit = is_numeric($Limit) && $Limit > 0 ? $Limit : $this->Limit;
         $this->TotalRecords = $TotalRecords;
         $this->_LastOffset = $this->Offset + $this->Limit;
         $this->_Totalled = ($this->TotalRecords >= $this->Limit) ? FALSE : TRUE;
         if ($this->_LastOffset > $this->TotalRecords)
            $this->_LastOffset = $this->TotalRecords;
               
         $this->_PropertiesDefined = TRUE;
         
         Gdn::Controller()->EventArguments['Pager'] = $this;
         Gdn::Controller()->FireEvent('PagerInit');
      }
   }
1178736
protected function addChange($calendarId, $objectUri, $operation)
    {
        $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarChangesTableName.' (uri, synctoken, calendarid, operation) SELECT ?, synctoken, ?, ? FROM '.$this->calendarTableName.' WHERE id = ?');
        $stmt->execute([
            $objectUri,
            $calendarId,
            $operation,
            $calendarId,
        ]);
        $stmt = $this->pdo->prepare('UPDATE '.$this->calendarTableName.' SET synctoken = synctoken + 1 WHERE id = ?');
        $stmt->execute([
            $calendarId,
        ]);
    }
216131
protected function applyTargetFieldConfig(array $config)
    {
        if (!isset($config['targetField']) || !is_string($config['targetField'])) {
            throw new UnexpectedValueException($this->translate(
                'Relation field configuration should contain target field name and name should be a string.'
            ));
        }
        $this->targetFieldName = $config['targetField'];
    }