update

@param bool $updateNulls

@return  static
@throws \Exception
487327
public function update($updateNulls = false)
    {
        // Event
        $this->triggerEvent(
            'onBefore' . ucfirst(__FUNCTION__),
            [
                'updateNulls' => &$updateNulls,
            ]
        );

        $this->triggerEvent(
            'onBeforeStore',
            [
                'updateNulls' => &$updateNulls,
            ]
        );

        // Do Action
        $this->getDataMapper()->updateOne($this, $this->getKeyName(true), $updateNulls);

        // Event
        $this->triggerEvent(
            'onAfterStore',
            [
                'updateNulls' => &$updateNulls,
            ]
        );

        $this->triggerEvent('onAfter' . ucfirst(__FUNCTION__));

        return $this;
    }
429510
public function update(array $values)
    {
        $result = parent::update($values);

        $this->handler->setBuilder($this)
            ->invalidateQuery(Reflector::QUERY_TYPE_UPDATE, $values);

        return $result;
    }
142667
public function update(array $values)
    {
        // update timestamps
        $values = $this->addUpdatedAtColumn($values);

        // get version values & values
        $versionValues = $this->getVersionValues($values);
        $values = $this->getValues($values);

        // get records
        $affectedRecords = $this->getAffectedRecords();

        // update main table records
        if (! $this->query->increment($this->model->getLatestVersionColumn(), 1, $values)) {
            return false;
        }

        // update version table records
        $db = $this->model->getConnection();
        foreach ($affectedRecords as $record) {
            // get versioned values from record
            foreach($this->model->getVersionedAttributeNames() as $key) {
                $recordVersionValues[$key] = (isset($versionValues[$key])) ? $versionValues[$key] : $record->{$key};
            }

            // merge versioned values from record and input
            $recordVersionValues = array_merge($recordVersionValues, $versionValues);

            // set version and ref_id
            $recordVersionValues[$this->model->getVersionKeyName()] = $record->{$this->model->getKeyName()};
            $recordVersionValues[$this->model->getVersionColumn()] = $record->{$this->model->getLatestVersionColumn()}+1;

            // insert new version
            if(! $db->table($this->model->getVersionTable())->insert($recordVersionValues)) {
                return false;
            }
        }

        // fill the latest version value
        $this->model->{$this->model->getLatestVersionColumn()} += 1;

        return true;
    }
16836
public function isUpdate($update = true, $where = null)
    {
        if (is_bool($update)) {
            $this->exists = $update;

            if (!empty($where)) {
                $this->updateWhere = $where;
            }
        } else {
            $this->exists      = true;
            $this->updateWhere = $update;
        }

        return $this;
    }
828993
public function update($fields) {
        if (is_array($fields)) {
            foreach ($fields as $key => $value) {
                if (is_string($value)) {
                    array_push($this->_updates, $key . ' = \'' . addslashes($value) . '\'');
                } else {
                    array_push($this->_updates, $key . ' = ' . $value);
                }
            }
        } else {
            return false;
        }
        
        $sql_query = 'UPDATE ' . $this->_table . 
                     ' SET ' . implode($this->_updates, ', ');
        
        // Where statements
        if (count($this->_where)) {
            $sql_query .= ' WHERE ';
            $sql_query .= implode($this->_where, ' AND ');
            
            // or statements
            if (count($this->_or)) {
                $sql_query .= ' OR ';
                $sql_query .= implode($this->_or, ' AND ');
            }
        }
        
        // Set the query
        $this->_sql_query = $sql_query;
        
        return $this;
    }
209528
public function update($update, $alias = null)
    {
        $this->type = self::UPDATE;

        $this->from($update, $alias);

        return $this;
    }
938651
private function doUpdate(array $changes) {
        $db     = $this->db();
        $entity = $this->dao()->getEntityMapping();
        $table  = $entity->getTableName();

        // collect identity infos
        $identity = $entity->getIdentity();
        $idColumn = $identity->getColumn();
        $idValue  = $identity->convertToDBValue($this->getObjectId(), $db);

        // collect version infos
        $versionMapping = $versionName = $versionColumn = $oldVersion = null;
        //if ($versionMapping = $entity->getVersion()) {
        //    $versionName   = $versionMapping->getName();
        //    $versionColumn = $versionMapping->getColumn();
        //    $oldVersion    = $object->getSnapshot()->$versionName;        // TODO: implement dirty check via snapshot
        //    $oldVersion    = $versionMapping->convertToDBValue($oldVersion, $db);
        //}

        // create SQL
        $sql = 'update '.$table.' set';                                     // update table
        foreach ($changes as $name => $value) {                             //    set ...
            $mapping     = $entity->getProperty($name);                     //        ...
            $columnName  = $mapping->getColumn();                           //        ...
            $columnValue = $mapping->convertToDBValue($value, $db);         //        column1 = value1,
            $sql .= ' '.$columnName.' = '.$columnValue.',';                 //        column2 = value2,
        }                                                                   //        ...
        $sql  = strLeft($sql, -1);                                          //        ...
        $sql .= ' where '.$idColumn.' = '.$idValue;                         //    where id = value
        if ($versionMapping) {                                              //        ...
            $op   = $oldVersion=='null' ? 'is':'=';                         //        ...
            $sql .= ' and '.$versionColumn.' '.$op.' '.$oldVersion;         //      and version = oldVersion
        }

        // execute SQL and check for concurrent modifications
        if ($db->execute($sql)->lastAffectedRows() != 1) {
            if ($versionMapping) {
                $this->reload();
                $msg = 'expected version: '.$oldVersion.', found version: '.$this->$versionName;
            }
            else $msg = 'record not found';
            throw new ConcurrentModificationException('Error updating '.get_class($this).' (oid='.$this->getObjectId().'), '.$msg);
        }
        return true;
    }
178311
public function updateDefault(array $params = [])
    {
        return $this->executeRequest(
            RequestMethodEnum::PUT,
            ResourceMethodEnum::UPDATE_DEFAULT,
            $params,
            null
        );
    }
230561
public static function update($table = null)
    {
        $query = new Update();

        if ($table) {
            $query->table($table);
        }

        return $query;
    }
708765
public function update($reset = true)
    {
        $this->explainer->info('Pulling changes');
        $tasks = [$this->vcs->update()];

        // Reset if requested
        if ($reset) {
            array_unshift($tasks, $this->vcs->reset());
        }

        return $this->bash->runForCurrentRelease($tasks);
    }
926146
public function store($updateNulls = false)
    {
        $date = JFactory::getDate();
        $user = JFactory::getUser();

        $this->modified_time = $date->toSql();

        if ($this->id)
        {
            // Existing category
            $this->modified_user_id = $user->get('id');
        }
        else
        {
            // New category. A category created_time and created_user_id field can be set by the user,
            // so we don't touch either of these if they are set.
            if (!(int) $this->created_time)
            {
                $this->created_time = $date->toSql();
            }

            if (empty($this->created_user_id))
            {
                $this->created_user_id = $user->get('id');
            }

        }

        // Verify that the alias is unique
        $table = JTable::getInstance('Categories', 'CategoriesTable', array('dbo' => $this->getDbo()));

        if ($table->load(array('alias' => $this->alias, 'parent_id' => (int) $this->parent_id, 'extension' => $this->extension))
            && ($table->id != $this->id || $this->id == 0))
        {
            $this->setError(JText::_('JLIB_DATABASE_ERROR_CATEGORY_UNIQUE_ALIAS'));

            return false;
        }

        return parent::store($updateNulls);
    }
983541
public function update($params = [])
    {
        $id = Arr::get($params, 'id', null);

        if (!$id) {
            throw new InvalidArgumentException('We need an id');
        }

        // json_patch required
        return $this->gateway->commit('patch', $this->gateway->buildUrlFromString('notifications/webhooks/'.$id), [], $params);
    }
203645
public function update($models)
    {
        $this->initIndex($models->first());
        $this->tnt->selectIndex("{$models->first()->searchableAs()}.index");
        $index = $this->tnt->getIndex();
        $index->setPrimaryKey($models->first()->getKeyName());

        $index->indexBeginTransaction();
        $models->each(function ($model) use ($index) {
            $array = $model->toSearchableArray();

            if (empty($array)) {
                return;
            }

            if ($model->getKey()) {
                $index->update($model->getKey(), $array);
            } else {
                $index->insert($array);
            }
        });
        $index->indexEndTransaction();
    }
1110632
public function update($table, array $updateFields)
    {
        $this->queryTypeProcess(self::QUERYTYPE_UPDATE, $table, $updateFields);
        return $this;
    }
628204
public function update()
    {
        $query = 'update '.$this->getTables($this->tables).' set ';
        //
        for ($i = 0; $i < Collection::count($this->sets); $i++) {
            if ($i < Collection::count($this->sets) - 1) {
                $query .= $this->sets[$i].',';
            } else {
                $query .= $this->sets[$i];
            }
        }
        //
        $query .= ' '.$this->where;
        //
        $this->reset();
        //
        return Database::exec($query);
    }
1321747
protected function visitSirelNodeUpdateStatement(Node\UpdateStatement $update)
    {
        $query = join(' ', array_filter(array(
            "UPDATE",
            $this->visit($update->relation),

            // SET
            "SET " . join(', ', $this->visitEach($update->values)),

            // WHERE
            ($update->restrictions
                ? "WHERE " . join(" AND ", $this->visitEach($update->restrictions))
                : null
            ),

            // ORDER BY
            ($update->orders
                ? "ORDER BY " . join(", ", $this->visitEach($update->orders))
                : null)
        )));

        $query = $this->platform->modifyLimitQuery($query, $update->limit->getExpression(), $update->offset->getExpression());
        $query .= ';';

        return $query;
    }
818999
public static function createFromArray(array $updates)
    {
        $update = new MapUpdate();

        foreach ($updates as $key => $val) {

            if (is_bool($val)) {
                $update->updateFlag($key, new FlagOp($val));

                continue;
            }

            if (is_string($val)) {
                $update->updateRegister($key, new RegisterOp($val));

                continue;
            }

            if (is_int($val)) {
                $update->updateCounter($key, new CounterOp($val));

                continue;
            }

            if (is_array($val) && ($val === array_values($val))) {

                $update->updateSet($key, new SetOp($val, []));

                continue;
            }

            if (is_array($val)) {

                $update->updateMap($key, self::createFromArray($val)->getOp());

                continue;
            }

            $message = 'Map element "%s" must be of the type (boolean, string, integer, or an array), "%s" given.';
            $type    = is_object($val) ? get_class($val) : gettype($val);

            throw new InvalidArgumentException(sprintf($message, $key, $type));
        }

        return $update;
    }