Update and save filter corresponding to the model, refresh chain values.

@return bool
340742
public function save()
    {
        // get the filter model based on the current filter.
        $filterModel = $this->findModel();
        // update the name of the filter if changed
        if ($filterModel->name !== $this->name()) {
            $filterModel->setAttribute('name', $this->name());
            $filterModel->update(false);
            $this->addLog("Filter name '".$this->name()."' have been updated for identifier '".static::identifier()."'.");
        }
        // array containing the processed chain ids
        $processed = [];

        $removeImages = false;
        
        foreach ($this->getChain() as $chain) {
            // get filter chain for filter and effect
            $model = StorageFilterChain::find()->where(['filter_id' => $filterModel->id, 'effect_id' => $chain['effect_id']])->one();
            if ($model) {
                if (md5($chain['effect_json_values']) != md5(Json::encode($model->effect_json_values))) {
                    $model->effect_json_values = $chain['effect_json_values'];
                    if ($model->update(false)) {
                        $removeImages = true;
                        $this->addLog("[!] {$filterModel->name}: effect chain has changed.");
                    }
                }
            } else {
                $model = new StorageFilterChain();
                $model->setAttributes(['filter_id' => $filterModel->id, 'effect_id' => $chain['effect_id'], 'effect_json_values' => $chain['effect_json_values']]);
                if ($model->save(false)) {
                    $removeImages = true;
                    $this->addLog("[+] {$filterModel->name}: Effect chain option/s have been added.");
                }
            }
            $processed[] = $model->id;
        }
        // remove not used chains for the current filter
        foreach (StorageFilterChain::find()->where(['not in', 'id', $processed])->andWhere(['=', 'filter_id', $filterModel->id])->all() as $deletion) {
            $this->addLog("[-] {$filterModel->name}: Effect chain option/s have been removed.");
            $deletion->delete();
            $removeImages = true;
        }
        
        if ($removeImages) {
            $this->addLog("[!] {$filterModel->name}: Remove images.");
            $removeLog = $filterModel->removeImageSources();
            foreach ($removeLog as $id => $sucess) {
                if ($sucess) {
                    $this->addLog('✓ image ' . $id . ' sucessfull unlinked.');
                } else {
                    $this->addLog('⨯ error while unlinking image id ' . $id);
                }
            }
        }

        return true;
    }
1227106
public function save() {
        global $DB;
        if (!$this->dirty) {
            return true;
        }
        $fordb = new StdClass();
        foreach (array('id', 'name', 'plugin', 'visible') as $field) {
            $fordb->{$field} = $this->{$field};
        }
        $DB->update_record('portfolio_instance', $fordb);
        $this->dirty = false;
        return true;
    }
1160594
public function updateOrderStatus()
    {
        $orderUpdated = false;
        $order = $this->getOrder();

        if (!is_null($order)) {
            $orderPayment = $this->getOrderPayment();
            $order = $this->recalculateAmounts($order);
            $newOrderStatus = $this->calculateOrderStatus($orderPayment, $order);
            $this->persistNewOrderStatus($order, $newOrderStatus);
            $orderUpdated = true;
        }

        return $orderUpdated;
    }
363855
public function Save(){
        if($this->transactionActive) {
            try {
                $this->commit();
                $this->exec("SET FOREIGN_KEY_CHECKS = 1;");
            } catch (\Exception $e) {
                $this->rollBack();
                echo $e->getMessage();
            }

            $this->transactionActive = false;
        }

        return false;
    }
3436
public function refresh()
    {
        if (! $this->exists) {
            return $this;
        }

        $this->setRawAttributes(
            static::newQueryWithoutScopes()->findOrFail($this->getKey())->attributes
        );

        $this->load(collect($this->relations)->except('pivot')->keys()->toArray());

        $this->syncOriginal();

        return $this;
    }
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;
	}
1138076
public function commit()
    {
        list($old, $new) = $this->generateRollback();
        $updates = $this->generateUpdates();
        $updates = $this->combineUpdates($updates);
        usort($updates, array($this, 'sortUpdates'));

        foreach ($updates as $update) {
            // apply update to cache & receive a simple bool to indicate
            // success (true) or failure (false)
            $success = call_user_func_array($update[1], $update[2]);
            if ($success === false) {
                $this->rollback($old, $new);

                return false;
            }
        }

        $this->clear();

        return true;
    }
69582
public function save()
    {

        $fields = array_except($this->attributes, ["_index", "_type", "_id", "_score"]);

        if ($this->exists()) {

            // Update the current document

            $this->newQuery()->id($this->getID())->update($fields);

        } else {

            // Check if model key exists in items

            if (array_key_exists("_id", $this->attributes)) {
                $created = $this->newQuery()->id($this->attributes["_id"])->insert($fields);
                $this->_id = $this->attributes["_id"];
            } else {
                $created = $this->newQuery()->insert($fields);
                $this->_id = $created->_id;
            }

            $this->setConnection($this->getConnection());
            $this->setIndex($created->_index);

            // Match earlier versions

            $this->_index = $created->_index;
            $this->_type = $this->type;

            $this->exists = true;
        }

        return $this;
    }
644205
public function save() :bool {
		
		// if an id already exists
		if($this->_['id']) {
			// we can update and return the number of affected rows (0 on error, 1 on success)
			return (bool) self::_update()
				->set($this->__toArray(true, true))
				->where(['id'=>$this->_['id']])
				->execute();
		}
		// this is a new record
		else {
			// try to insert it
			$inserted_object = self::create($this->__toArray(true, true));
			// if insertion succeeded, return true
			if($inserted_object) {
				// clone ourselves with what the database returneds, a full fledged object
				$this->replicate($inserted_object);
				// return success
				return true;
			}
			// didnt insert
			else {
				// failure feedback
				return false;
			}
		}
		
	}
438826
public function save()
    {
        if (!$this->isNew()) {
            $this->setStatus(self::STATUS_UPDATED);
        } else {
            $this->setStatus(self::STATUS_CREATED);
        }

        return false;
    }
483005
public function save()
    {

        $ok = $this->dataConnector->saveToolConsumer($this);
        if ($ok) {
            $this->settingsChanged = false;
        }

        return $ok;

    }
457399
public function savePolicy()
    {
        if ($this->isFiltered()) {
            throw new CasbinException('cannot save a filtered policy');
        }

        $this->adapter->savePolicy($this->model);

        if (null !== $this->watcher) {
            return $this->watcher->update();
        }
    }
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;
    }
1265928
public function save()
    {
        
        $this->updateTimestamps();

         /**
         * If this is a unique relationship we should check for an existing
         * one of the same type and direction for the $parent node before saving
         * and delete it, only if we are not updating a relationship.
         */
        if ($this->unique and ! $this->exists())
        {
            
            $parent = $this->asNode($this->parent);
           
//              //Check if relationship already exist
//            $existing = $parent->getFirstRelationship((array) $this->type, $this->getRealDirection($this->direction));
//  
//            if ( ! empty($existing))
//            {
//                $existing->delete();
//            }
        }

        $this->setRelationProperties($this->toArray());

        $saved = $this->query->insertRelationship($this->parent, $this->related, $this->relation, $values=[]);


        if ($saved)
        {
            // Let's refresh the relation we alreay have set so that
            // we make sure that it is totally in sync with the saved one.
           // $this->setRelation($this->relation);

            return true;
        }

        return  false;
    }
1045771
protected function performUpdate()
    {
        // If the updating event returns false, we will cancel the update operation so
        // developers can hook Validation systems into their models and cancel this
        // operation if the model does not pass validation. Otherwise, we update.
        if ($this->fireModelEvent('updating') === false) {
            return false;
        }

        // First we need to create a fresh query instance and touch the creation and
        // update timestamp on the model which are maintained by us for developer
        // convenience. Then we will just continue saving the model instances.
        if ($this->usesTimestamps()) {
            $this->updateTimestamps();
        }

        // Once we have run the update operation, we will fire the "updated" event for
        // this model instance. This will allow developers to hook into these after
        // models are updated, giving them a chance to do any special processing.
        $dirty = $this->getDirty();

        if (count($dirty) > 0) {
            static::$client::update($this->getKey(), $dirty, $this->attributes);

            $this->fireModelEvent('updated', false);

            $this->syncChanges();
        }

        return true;
    }
660865
public function push()
	{
		if ( ! $this->save()) return false;

		// To sync all of the relationships to the database, we will simply spin through
		// the relationships and save each model via this "push" method, which allows
		// us to recurse into all of these nested relations for the model instance.
		foreach ($this->relations as $models)
		{
			$models = $models instanceof Collection
						? $models->all() : array($models);

			foreach (array_filter($models) as $model)
			{
				if ( ! $model->push()) return false;
			}
		}

		return true;
	}
18228
public function save()
    {
        // Validate
        if (!$this->validates()) {
            return false;
        }

        // Run filter
        $this->runFilters('before', $this->_isNew ? 'create' : 'save');

        // Get data
        $data = static::data();

        // Create
        if ($this->_isNew) {
            $result = static::connection()
                ->insert($data)
                ->into(static::table())
                ->exec();

            $this->id = static::connection()->lastInsertId();
        }
        // Update
        else {
            $result = static::connection()
                ->update(static::table())
                ->set($data)
                ->where(static::$_primaryKey . ' = ?', $data[static::$_primaryKey])
                ->exec();
        }

        // Run filters
        $this->runFilters('after', $this->_isNew ? 'create' : 'save');

        return $result;
    }