Updates an existing item in the database

@return  bool
@since   2.0.0
482273
private function modify()
	{
		// Add any automatic fields
		$this->parseAutomatics('renew');
		$data = $this->getTableColumnsOnly();
		// Return the result of the query
		return $this->query->alter(
			$this->getTableName(),
			$this->getPrimaryKey(),
			$this->getPkValue(),
			$data
		);
	}
639839
public function update()
    {
        $this->apply(function ($config) {
            $foreignKey = snake_case($this->key($config['foreignKey']));
            $amount = $this->model->{$config['columnToSum']};

            if ($this->model->getOriginal($foreignKey) && $this->model->{$foreignKey} != $this->model->getOriginal($foreignKey)) {
                $this->updateCacheRecord($config, '-', $amount, $this->model->getOriginal($foreignKey));
                $this->updateCacheRecord($config, '+', $amount, $this->model->{$foreignKey});
            }
        });
    }
721420
public function update($db=''){
		if ( empty($db) ){
			$db = $this->db->current;
		}
		if ( bbn\str::check_name($db) ){

      $this->db->clear_all_cache();

			$change = $this->db->current === $db ? false : $this->db->current;
			if ( $change ){
				$this->db->change($db);
			}
			$schema = $this->db->modelize();
			if ( $change ){
				$this->db->change($change);
			}
      /*
			$projects = [];
			$r1 = $this->db->query("SELECT *
			FROM `{$this->admin_db}`.`{$this->prefix}projects`
			WHERE `db` LIKE '$db'");
			while ( $d1 = $r1->get_row() ){
				$projects[$d1['id']] = $d1;
				$projects[$d1['id']]['forms'] = [];
				$r2 = $this->db->query("
					SELECT id
					FROM `{$this->admin_db}`.`{$this->prefix}forms`
					WHERE `id_project` = ?",
					$d1['id']);
				while ( $d2 = $r2->get_row() ){
					$projects[$d1['id']]['forms'][$d2['id']] = $this->get_form_config();
				}
			}
			*/
			$this->db->insert_ignore($this->admin_db.'.'.$this->prefix.'dbs',[
        'id' => $db,
        'db' => $db,
        'host' => $this->db->host
      ]);
      $tab_history = false;
      if ( bbn\appui\history::$is_used && isset($schema[bbn\appui\history::$htable]) ){
        $tab_history = 1;
      }
      if ( !\is_array($schema) ){

        die(var_dump("THIS IS NOT AN ARRAY", $schema));
      }

			foreach ( $schema as $t => $vars ){
        $col_history = $tab_history;
				if ( isset($vars['fields']) ){
          $tmp = explode(".", $t);
          $db = $tmp[0];
          $table = $tmp[1];
					$this->db->insert_update($this->admin_db.'.'.$this->prefix.'tables',[
						'id' => $t,
						'db' => $db,
						'table' => $table
					]);
          if ( $col_history && !array_key_exists(bbn\appui\history::$hcol, $vars['fields']) ){
            $col_history = false;
          }
          foreach ( $vars['fields'] as $col => $f ){
    				$config = new \stdClass();
						if ( $col_history && ($col !== bbn\appui\history::$hcol) ){
							$config->history = 1;
						}
						if ( !empty($f['extra']) ){
							$config->extra = $f['extra'];
						}
						if ( isset($f['signed']) && $f['signed'] == 1 ){
							$config->signed = 1;
						}
						if ( isset($f['null']) && $f['null'] == '1' ){
							$config->null = 1;
						}
						if ( isset($f['maxlength']) && $f['maxlength'] > 0 ){
							$config->maxlength = (int)$f['maxlength'];
						}
						if ( isset($f['keys']) ){
							$config->keys = [];
							foreach ( $f['keys'] as $key ){
								$config->keys[$key] = $vars['keys'][$key];
							}
						}
						$this->db->insert_update($this->admin_db.'.'.$this->prefix.'columns',[
							'id' => $t.'.'.$col,
							'table' => $t,
							'column' => $col,
							'position' => $f['position'],
							'type' => $f['type'],
							'null' => $f['null'],
              'key' => $f['key'],
              'default' => $f['default'],
							'config' => json_encode($config)
						]);
					}
				}
			}
      foreach ( $schema as $t => $vars ){
        if ( isset($vars['keys']) && \is_array($vars['keys']) ){
          foreach ( $vars['keys'] as $k => $arr ){
            $pos = 1;
            foreach ( $arr['columns'] as $c ){
              $this->db->insert_update($this->admin_db.'.'.$this->prefix.'keys', [
                'id' => $t.'.'.$k,
                'key' => $k,
                'table' => $t,
                'column' => $t.'.'.$c,
                'position' => $pos,
                'ref_column' => \is_null($arr['ref_column']) ? null : $arr['ref_db'].'.'.$arr['ref_table'].'.'.$arr['ref_column'],
                'unique' => $arr['unique']
              ]);
              $pos++;
            }
          }
        }
      }
      /*
			foreach ( $projects as $i => $p ){
				$this->db->insert($this->admin_db.'.'.$this->prefix.'projects',[
					'id' => $i,
					'id_client' => $p['id_client'],
					'db' => $p['db'],
					'name' => $p['name'],
					'config' => $p['config']]);
				foreach ( $p['forms'] as $j => $form ){
					$this->db->insert($this->admin_db.'.'.$this->prefix.'forms',[
						'id' => $j,
						'id_project' => $i
					]);
					foreach ( $form as $field ){
						$this->db->insert_ignore($this->admin_db.'.'.$this->prefix.'fields',[
							'id' => $field['id'],
							'id_form' => $j,
							'column' => $field['column'],
							'title' => $field['title'],
							'position' => $field['position'],
							'configuration' => json_encode($field['configuration'])
						]);
					}
				}
			}
       * 
       */
      $this->db->enable_keys();
		}
	}
654443
public function save(): bool
	{
		$success = true;

		if(!$this->isPersisted)
		{
			// This is a new record so we need to insert it into the database.

			$this->insertRecord($this->builder());

			$this->isPersisted = true;
		}
		elseif($this->isModified())
		{
			// This record exists and is modified so all we have to do is update it.

			$success = $this->updateRecord($this->builder());
		}

		if($success)
		{
			// Sync up if save was successful

			$this->synchronize();
		}

		return $success;
	}
756213
protected function update()
	{
		// New objects can't be updated, neither can frozen
		if ($this->is_new())
		{
			return false;
		}

		// Non changed objects don't have to be saved, but return true anyway (no reason to fail)
		if ( ! $this->is_changed(array_keys(static::properties())))
		{
			return true;
		}

		$this->observe('before_update');

		// Create the query and limit to primary key(s)
		$query       = Query::forge(get_called_class(), static::connection(true));
		$primary_key = static::primary_key();
		$properties  = array_keys(static::properties());
		//Add the primary keys to the where
		$this->add_primary_keys_to_where($query);

		// Set all current values
		foreach ($properties as $p)
		{
			if ( ! in_array($p, $primary_key) )
			{
				if (array_key_exists($p, $this->_original))
				{
					$this->{$p} !== $this->_original[$p] and $query->set($p, isset($this->_data[$p]) ? $this->_data[$p] : null);
				}
				else
				{
					array_key_exists($p, $this->_data) and $query->set($p, $this->_data[$p]);
				}
			}
		}

		// Return false when update fails
		if ( ! $query->update())
		{
			return false;
		}

		// update the original property on success
		$this->observe('after_update');

		return true;
	}
1016803
protected function _update()
    {
        $query = $this->_queryClass;
        $bindKey = PdoBindHelper::generateBindKey();
        $result = DbConnector::getAdapter()->update((new $query)->getTableName(), $this->_truncateToStructure(true), $this->_pkWhere($bindKey), [$bindKey => $this->getInitialStateValue('id')]);
        //utrwalanie bieżącego stanu
        $this->clearModified();
        return ($result >= 0);
    }
917795
public function update()
    {
        $conditions = $this->infosMergeds['fields_and_values'];

        $this->sql = new PhiberQueryWriter("update", [
            "table"  => $this->table,
            "fields" => $this->fields,
            "values" => $this->fieldsValues,
            "where"  => isset($this->infosMergeds['where']) ?
                $this->infosMergeds['where'] :
                null,
            "limit"  => isset($this->infosMergeds['limit']) ?
                $this->infosMergeds['limit'] :
                null,
            "offset"  => isset($this->infosMergeds['offset']) ?
                $this->infosMergeds['offset'] :
                null
        ]);

        if ($this->phiberConfig->verifyExecuteQueries()) {

            $this->PDO = $this->PDO->prepare($this->sql);
            for ($i = 0; $i < count($this->fields); $i++) {
                if (!empty($this->fieldsValues[$i])) {
                    $this->PDO->bindValue($this->fields[$i], $this->fieldsValues[$i]);
                }
            }

            while (current($conditions)) {
                $this->PDO->bindValue(
                    "condition_" . key($conditions), 
                    $conditions[key($conditions)]
                );
                
                next($conditions);
            }

            if ($this->PDO->execute()) {
                return true;
            }
        }

        return false;
    }
60877
public function update()
    {
        $s = new static();

        $where = "id = {$s::$ID}";

        return self::$db->update($s::$entity_table, $this->db_fields, $where);
    }
287697
public function update() {
        $this->isNewRecord = false;
        if ($this->usesTimestamps()) {
            $this->updateTimestamps();
        }
        $this->invoke(self::BEFORE_UPDATE, [$this]);
        if (!$this->validate()) {
            return false;
        }
        $query = $this->getPrimaryKeyQuery();
        if (empty($query)) {
            $this->setError('pk', 'ERROR PK!');
            return false;
        }
        $data = $this->_getRealFields();
        if (empty($data)) {
            return true;
        }
        $row = $query
            ->update($data);
        if (!empty($row)) {
            $this->setOldAttribute();
        } else {
            $this->setError('data', 'Data is not change!');
        }
        $this->invoke(self::AFTER_UPDATE, [$this]);
        return $row;
    }
182204
protected function __update()
	{
		/** Rebase array indices */
		parent::__update();

		if ( $this->count() && $this->attribute instanceof DOMAttr ) {
			$this->attribute->value = (string) $this;
		}
	}
554824
public function update()
    {
        $result = $this->connection()->patch($this->getEndpoint() . '/' . urlencode($this->id), $this->jsonWithNamespace());
        if ($result === 200) {
            return true;
        }

        return $this->selfFromResponse($result);
    }
319164
function save()
    {
        if ($this->id != false || $this->id != 0) {
            return $this->update();
        } else {
            return $this->insert();
        }
    }
1028096
public function updateSQL()
	{
		try{

			//check if table update values are set
			if($this->update_table['drop'] || $this->update_table['rename'])
			{
				//compose query string
				$this->query_string = ($this->update_table['drop']) ? "DROP TABLE IF EXISTS {$this->table};" : "ALTER TABLE {$this->table} RENAME TO {$this->update_table['rename']};";

				return $this;

			}

			//do column updates
			else
			{
				$lines = array();
				$template = "ALTER TABLE %s\n %s;";
				//loop through the columns available
				foreach($this->columns as $column_name => $column)
				{
					//start with less trivial goin upward ADD COLUMN complete DECIMAL(2,1) NULL AFTER description;
					if($column['add'])
					{
						$data_type = $column["type"];//set the column data type

						$length = $column["length"];//set the lenght of the data type

						$primary = ($column["primary"])	? "PRIMARY KEY " : null;//({$column_name})"; //add primary key field

						$index = ($column["index"]) ? "KEY" : null;// {$column_name} ({$column_name})"; //add index field

						switch ($data_type)
						{
							case "autonumber":

								$lines[] = "ADD COLUMN {$column_name} INT(11) NOT NULL AUTO_INCREMENT $primary AFTER {$column['add']}\n";

								break;

							case "text":

								if ($length !== null && $length <= 255)	$lines[] = "ADD COLUMN {$column_name} VARCHAR({$length}) DEFAULT NULL AFTER {$column['add']}\n";

								else $lines[] = "ADD COLUMN {$column_name} text DEFAULT NULL  AFTER {$column['add']}\n";

								break;

							case "integer":

								$lines[] = "ADD COLUMN {$column_name} INT(11) DEFAULT NULL AFTER {$column['add']}\n";

								break;

							case "decimal":

								$lines[] = "ADD COLUMN {$column_name} FLOAT DEFAULT NULL AFTER {$column['add']}\n";

								break;

							case "boolean":

								$lines[] = "ADD COLUMN {$column_name} TINYINT(4) DEFAULT NULL AFTER {$column['add']}\n";

								break;

							case "datetime":

								$lines[] = "ADD COLUMN {$column_name} DATETIME DEFAULT NULL AFTER {$column['add']}\n";

								break;

						}

					}

					elseif($column['update'])
					{

						$data_type = $column["type"];//set the column data type

						$length = $column["length"];//set the lenght of the data type

						$primary = ($column["primary"])	? "PRIMARY KEY " : null;//({$column_name})"; //add primary key field

						$index = ($column["index"]) ? "KEY" : null;// {$column_name} ({$column_name})"; //add index field

						switch ($data_type) //CHANGE COLUMN task_id task_id INT(11) NOT NULL AUTO_INCREMENT;
						{
							case "autonumber":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} INT(11) NOT NULL AUTO_INCREMENT $primary\n";

								break;

							case "text":

								if ($length !== null && $length <= 255)	$lines[] = "ADD COLUMN {$column_name} VARCHAR({$length}) DEFAULT NULL\n";

								else $lines[] = "CHANGE COLUMN {$column_name} {$column_name} text DEFAULT NULL\n";

								break;

							case "integer":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} INT(11) DEFAULT NULL\n";

								break;

							case "decimal":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} FLOAT DEFAULT NULL\n";

								break;

							case "boolean":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} TINYINT(4) DEFAULT NULL\n";

								break;

							case "datetime":

								$lines[] = "CHANGE COLUMN {$column_name} {$column_name} DATETIME DEFAULT NULL\n";

								break;

						}
	
					}

					elseif($column['rename'])
					{
						//$lines[] = "CHANGE COLUMN `{$column_name}` `{$column['rename']}`\n";
					}

					elseif($column['drop'])
					{
						$lines[] = "DROP COLUMN {$column['drop']}\n";


					}

				}

				$this->query_string = sprintf($template, $this->table, join(',',$lines));

				return $this;

			}

		}

		catch (MySLQException $err){

			$err->errorShow();

		}

	}
1157973
public function UpdateItem()
    {
        $pathExpr = $this->SingleValuedPathExpression();

        $this->match(Lexer::T_EQUALS);

        $updateItem = new AST\UpdateItem($pathExpr, $this->NewValue());

        return $updateItem;
    }
1112781
public function update()
    {
        $now = new \DateTime();

        foreach ($this->toUpdate as $providerName => $urls) {
            foreach ($urls as $url) {
                $shares = $this->providers[$providerName]['provider']->getShares($url);

                $this->cache->save($this->getId($providerName, $url), array($shares, $now));
            }
        }
    }
706754
public function update()
    {
        try {
            Option::set(self::LAST_RUN_TIME_OPTION_NAME, Date::factory('today')->getTimestamp());

            $locUrl = Option::get(self::LOC_URL_OPTION_NAME);
            if (!empty($locUrl)) {
                $this->downloadFile('loc', $locUrl);
            }

            $ispUrl = Option::get(self::ISP_URL_OPTION_NAME);
            if (!empty($ispUrl)) {
                $this->downloadFile('isp', $ispUrl);
            }
        } catch (Exception $ex) {
            // message will already be prefixed w/ 'GeoIP2AutoUpdater: '
            Log::error($ex);
            $this->performRedundantDbChecks();
            throw $ex;
        }

        $this->performRedundantDbChecks();
    }
507571
protected function _update()
    {
        $this->_aSkipSaveFields = ['oxtimestamp', 'oxorderdate'];
        $this->oxorder__oxsenddate = new \OxidEsales\Eshop\Core\Field(\OxidEsales\Eshop\Core\Registry::getUtilsDate()->formatDBDate($this->oxorder__oxsenddate->value, true));

        return parent::_update();
    }