Update field in page table

@param integer      $pid         PID
@param integer|NULL $sysLanguage System language id
@param string       $fieldName   Field name
@param string       $fieldValue  Field value

@return array

@throws AjaxException
549625
public function updatePageTableField($pid, $sysLanguage, $fieldName, $fieldValue)
    {
        $tableName = 'pages';

        if (!empty($sysLanguage)) {
            // check if field is in overlay
            if ($this->isFieldInTcaTable('pages_language_overlay', $fieldName)) {
                // Field is in pages language overlay
                $tableName = 'pages_language_overlay';
            }
        }

        switch ($tableName) {
            case 'pages_language_overlay':
                // Update field in pages overlay (also logs update event and clear cache for this page)

                // check uid of pages language overlay
                $query     = 'SELECT uid
                                FROM pages_language_overlay
                               WHERE pid = ' . (int)$pid . '
                                 AND sys_language_uid = ' . (int)$sysLanguage;
                $overlayId = DatabaseUtility::getOne($query);

                if (empty($overlayId)) {
                    // No access

                    throw new AjaxException(
                        'message.error.no_language_overlay_found',
                        '[0x4FBF3C05]',
                        HttpUtility::HTTP_STATUS_BAD_REQUEST
                    );
                }

                // ################
                // UPDATE
                // ################

                $this->getDataHandler()->updateDB(
                    'pages_language_overlay',
                    (int)$overlayId,
                    array(
                        $fieldName => $fieldValue
                    )
                );
                break;
            case 'pages':
                // Update field in page (also logs update event and clear cache for this page)
                $this->getDataHandler()->updateDB(
                    'pages',
                    (int)$pid,
                    array(
                        $fieldName => $fieldValue
                    )
                );
                break;
        }

        return array();
    }
299430
protected function clearMetaTags($pid, $sysLanguage)
    {
        $query = 'DELETE FROM tx_metaseo_metatag
                        WHERE pid = ' . (int)$pid . '
                          AND sys_language_uid = ' . (int)$sysLanguage;
        DatabaseUtility::exec($query);
    }
1324381
public function update($id, array $fields)
    {
        $xml = "<employee>";

        foreach ($fields as $field => $value) {
            $xml .= "<field id=\"{$field}\">{$value}</field>";
        }

        $xml .= "</employee>";

        return $this->post("employees/{$id}", $xml);
    }
1174489
public function setUserTypeEntityEnumValues($fieldId, $newenums) {
        $newenums = is_array($newenums) ? $newenums : array();
        $oldenums = $this->getEnumValues($fieldId, true);

        $index = 0;

        $updates = array();
        foreach ($oldenums as $oldenum) {
            $newenum = $this->searchEnum($oldenum, $newenums);
            if ($newenum) {
                $updates[$oldenum['ID']] = $newenum;
            } else {
                $oldenum['DEL'] = 'Y';
                $updates[$oldenum['ID']] = $oldenum;
            }
        }

        foreach ($newenums as $newenum) {
            $oldenum = $this->searchEnum($newenum, $oldenums);
            if ($oldenum) {
                $updates[$oldenum['ID']] = $newenum;
            } else {
                $updates['n' . $index++] = $newenum;
            }
        }

        $obEnum = new \CUserFieldEnum();
        return $obEnum->SetEnumValues($fieldId, $updates);

    }
431234
public function field_type($name = NULL, $length = NULL, $fvalue = '')
	{
		if ($this->fieldtype === TRUE) {
			$select	= '<option value="">-</option>
				<option value="INT" '.($name == 'INT' ? 'selected' : '').'>INT</option>
				<option value="TINYINT" '.($name == 'TINYINT' ? 'selected' : '').'>TINYINT</option>
				<option value="SMALLINT" '.($name == 'SMALLINT' ? 'selected' : '').'>SMALLINT</option>
				<option value="MEDIUMINT" '.($name == 'MEDIUMINT' ? 'selected' : '').'>MEDIUMINT</option>
				<option value="">-</option>
				<option value="DECIMAL" '.($name == 'DECIMAL' ? 'selected' : '').'>DECIMAL</option>
				<option value="FLOAT" '.($name == 'FLOAT' ? 'selected' : '').'>FLOAT</option>
				<option value="">-</option>
				<option value="CHAR" '.($name == 'CHAR' ? 'selected' : '').'>CHAR</option>
				<option value="VARCHAR" '.($name == 'VARCHAR' ? 'selected' : '').'>VARCHAR</option>
				<option value="TEXT" '.($name == 'TEXT' ? 'selected' : '').'>TEXT</option>
				<option value="MEDIUMTEXT" '.($name == 'MEDIUMTEXT' ? 'selected' : '').'>MEDIUMTEXT</option>';
		} elseif (count($this->fieldtype) > 1) {
			$select	= '<option value="">-</option>';
			foreach ($this->fieldtype as $t) {
				$select	= "<option value=\"{$t}\" ".($name == $t ? "selected" : "").">{$t}</option>";
			}
		} else {
			return '
			<div class="hstui-form-group hstui-form-group-sm">
	          <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::fields.default.value').'</label>
	          <div class="hstui-u-sm-10 hstui-form-input">
	              <input type="text" name="setting[option][fvalue]" value="'.$fvalue.'" class="hstui-input hstui-length-5">
	            <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::fields.default.value.tips').'">'.hst_lang('hstcms::fields.default.value.tips').'</div>
	          </div>
	        </div>';
		}
		$str = '
			<div class="hstui-form-group hstui-form-group-sm">
	          <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::manage.fields.fieldtype').'</label>
	          <div class="hstui-u-sm-10 hstui-form-input">
	             	<select class="hstui-input hstui-textarea" name="setting[option][fieldtype]" onChange="setlength()" id="type">
						'.$select.'
					</select>
	            <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::manage.fields.fieldtype.tips').'">'.hst_lang('hstcms::manage.fields.fieldtype.tips').'</div>
	          </div>
	        </div>
			<div class="hstui-form-group hstui-form-group-sm">
	          <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::manage.fields.length.value').'</label>
	          <div class="hstui-u-sm-10 hstui-form-input">
	              <input type="text" name="setting[option][fieldlength]" value="'.$length.'" class="hstui-input hstui-length-5">
	            <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::manage.fields.length.value.tips').'">'.hst_lang('hstcms::manage.fields.length.value.tips').'</div>
	          </div>
	        </div>
			<div class="hstui-form-group hstui-form-group-sm">
	          <label class="hstui-u-sm-2 hstui-form-label">'.hst_lang('hstcms::fields.default.value').'</label>
	          <div class="hstui-u-sm-10 hstui-form-input">
	              <input type="text" name="setting[option][fvalue]" value="'.$fvalue.'" class="hstui-input hstui-length-5">
	            <div class="hstui-form-input-tips" id="J_form_tips_name" data-tips="'.hst_lang('hstcms::fields.default.value.tips').'">'.hst_lang('hstcms::fields.default.value.tips').'</div>
	          </div>
	        </div>';
		return $str; 
	}
6291
protected function getWidget($fieldName, $serializedId, $propertyValue)
    {
        $environment    = $this->getEnvironment();
        $property       = $environment->getDataDefinition()->getPropertiesDefinition()->getProperty($fieldName);
        $propertyValues = new PropertyValueBag();

        if (null !== $serializedId) {
            $model = $this->getModelFromSerializedId($serializedId);
        } else {
            $dataProvider = $environment->getDataProvider();
            $model        = $dataProvider->getEmptyModel();
        }

        $widgetManager = new ContaoWidgetManager($environment, $model);

        // Process input and update changed properties.
        $treeType      = \substr($property->getWidgetType(), 0, 4);
        $propertyValue = $this->getTreeValue($treeType, $propertyValue);
        if (('file' === $treeType) || ('page' === $treeType)) {
            $extra = $property->getExtra();
            if (\is_array($propertyValue) && !isset($extra['multiple'])) {
                $propertyValue = $propertyValue[0];
            } else {
                $propertyValue = \implode(',', (array) $propertyValue);
            }
        }

        $propertyValues->setPropertyValue($fieldName, $propertyValue);
        $widgetManager->processInput($propertyValues);
        $model->setProperty($fieldName, $propertyValues->getPropertyValue($fieldName));

        return $widgetManager->getWidget($fieldName);
    }
1342372
public function copyValueFromOtherStep(FieldList $fields, $formStep, $fieldName, $fieldNameTarget = null)
    {
        // if a target field isn't defined use the same fieldname
        if (!$fieldNameTarget) {
            $fieldNameTarget = $fieldName;
        }

        $fields->fieldByName($fieldNameTarget)->setValue($this->getValueFromOtherStep($formStep, $fieldName));
    }
661198
public function actionDelete( $id, $pid ) {

		$model	= $this->modelService->getById( $id );
		$parent = $this->parentService->getById( $pid );

		if( isset( $model ) && isset( $parent ) ) {

			$address = $this->addressService->getById( $model->modelId );

			// Delete Address and Mappings
			$this->addressService->delete( $address, [ 'admin' => true ] );

			// Trigger Ajax Success
			return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ) );
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
188635
public function updateFormFields(FieldList $fields, $controller, $formName, $context)
    {
        $image = isset($context['Record']) ? $context['Record'] : null;
        if ($image && $image->appCategory() === 'image') {
            $fields->insertAfter(
                'Title',
                FocusPointField::create('FocusPoint', $image->fieldLabel('FocusPoint'), $image)
                    ->setReadonly($formName === 'fileSelectForm')
            );
        }
    }
473208
@Override
  public final void setItsId(final IdUserRoleJetty pId) {
    this.itsId = pId;
    if (this.itsId == null) {
      this.itsUser = null;
      this.itsRole = null;
    } else {
      this.itsUser = this.itsId.getItsUser();
      this.itsRole = this.itsId.getItsRole();
    }
  }
88535
protected function setFieldValue($field_value_id)
    {
        $this->data_field_value = array();

        if (is_numeric($field_value_id)) {

            $conditions = array(
                'language' => 'und',
                'field_value_id' => $field_value_id
            );

            $this->data_field_value = $this->field_value->get($conditions);

            if (empty($this->data_field_value)) {
                $this->outputHttpStatus(404);
            }

            $this->prepareFieldValue($this->data_field_value);
        }
    }
33149
public void updateNewRelsExt(String pid) throws Exception {
        if (!hasRelsExt() && getTabIndex("New RELS-EXT...") == -1) {
            m_tabbedPane.insertTab("New RELS-EXT...",
                                   newIcon,
                                   new NewRelsExtDatastreamPane(m_owner,
                                                                pid,
                                                                this),
                                   "Add a RELS-EXT datastream to this object",
                                   getTabIndex("New..."));
            int i = getTabIndex("New RELS-EXT...");
            m_tabbedPane.setBackgroundAt(i, Administrator.DEFAULT_COLOR);
        } else if (hasRelsExt() && getTabIndex("New RELS-EXT...") != -1) {
            m_tabbedPane.remove(getTabIndex("New RELS-EXT..."));
        }
    }
859566
public function updateFieldValueValue(FieldValueInterface $fieldValue, $changeSet)
    {
        if (!isset($changeSet['value'])) {
            return;
        }

        $oldValue = unserialize($changeSet['value'][0]);
        $newValue = unserialize($changeSet['value'][1]);

        if ($newValue['src'] == '' && !$newValue['delete']) {
            $newValue['src'] = $oldValue['src'];
        }

        if ($newValue['delete']) {
            $this->uploadManager->remove($oldValue['src']);
        }

        unset($newValue['delete']);

        $fieldValue->setValue(serialize($newValue));
    }
270465
public function fillFieldWithValue(string $fieldName, $value, ?string $containerName = null): void
    {
        $newContainerName = (!$containerName) ? $containerName : sprintf($this::NEW_FIELD_TITLE_PATTERN, EzFieldElement::getFieldInternalNameByName($containerName));
        $fieldElement = $this->getField($fieldName, $newContainerName);
        $fieldElement->setValue($value);
    }
996620
protected function setFieldFieldValue($field_id)
    {
        $this->data_field = $this->field->get($field_id);

        if (empty($this->data_field)) {
            $this->outputHttpStatus(404);
        }
    }
1161096
public function update($fieldValues)
    {
        foreach ($fieldValues as $field => $value) {
            if ($value instanceof ExpressionInterface) {
                if ($value instanceof Increment) {
                    $fieldValues[] = "[$field]=[$field]" . ($value->step >= 0 ? '+' : '') . $value->step;
                } elseif ($value instanceof Raw) {
                    $fieldValues[] = "[$field]=" . $value->expression;
                }
                unset($fieldValues[$field]);
            }
        }

        return $this->getConnection()->update($this->getSource(), $fieldValues, $this->_conditions, $this->_bind);
    }
1019200
public function update($table_name, $id, array $data) {
            Event::dispatch(EventData::forBefore(Event::BEFORE_UPDATE, $table_name, $data), $data);


            $q = $this->config->getSystemIdentifierQuote();

            //update database record
            $sql_query = "UPDATE $q" . $table_name . "$q SET ";

            $statement_params = [':update_id' => $id];
            // keep track of null params for logging output. binding null params
            // was causing foreign key violations (for nullable fields)
            $null_params = [];
            foreach ($data as $field_name => $value) {
                if (strtolower($value) == 'null' || is_null($value)) {
                    $sql_query .= "\n$q" . $field_name . "$q = NULL,";
                    $null_params[ $field_name ] = 'NULL';
                } else {
                    $sql_query .= "\n$q" . $field_name . "$q = :" . $field_name . ",";
                    $statement_params[ ':' . $field_name ] = $value;
                }
            }

            $full_param_list = array_merge($null_params, $statement_params);

            $sql_query = substr($sql_query, 0, -1); // remove trailing comma
            $sql_query .= "\nWHERE $q" . 'id' . "$q = :update_id";
            $sql_query .= ";";

            try {
                //Run update query, collect stats
                $stmt = $this->db_connection->prepare($sql_query);
                if ($statement_params) {
                    foreach ($statement_params as $k => $v) {
                        $stmt->bindValue($k, $v);
                    }
                }

                $stmt->execute();
            } catch (Exception $ex) {
                Event::dispatch(EventData::forException($ex, $sql_query, $full_param_list));

                throw new QueryException($ex->getMessage(), $ex->getCode(), $ex);
            }

            $row_count = $stmt->rowCount();
            Event::dispatch(EventData::forAfter(Event::AFTER_UPDATE, $table_name, $full_param_list, $sql_query, $row_count));

            return $row_count;
        }