Saves the object to the database

@param mixed $item The item to save
@param bool $update The item to save

@return bool|object

@throws \Throwable
@throws \craft\errors\ElementNotFoundException
@throws \yii\base\Exception
967763
public function save($item, bool $update = false)
    {
        /** @var User $item */
        return Craft::$app->getElements()->saveElement($item);
    }
425003
public function save($object)
    {

        if (is_array($object)) {
            $objectData = $object;
            if ($object['id'] > 0) {
                $object = $this->find($object['id']);
            } else {
                $object = $this->createNewObject();
            }
            $this->assignArrayToObject($object, $objectData);
        } else if (!$this->isCorrectInstance($object)) {
            $this->addErrorMessage(self::ERROR_WRONG_OBJECT);
        }

        if (!$this->hasError()) {
            $check = $this->manager->save($object);
            if ($check) {
                $this->addSuccessMessage(self::SUCCESS_SAVED);
            }
        }

        return $object;
    }
168130
public function save($object)
    {

        if (is_array($object)) {
            $objectData = $object;
            if ($object['id'] > 0) {
                $object = $this->find($object['id']);
            } else {
                $object = new Group();
            }
            $this->assignArrayToObject($object, $objectData);
        } else if (!($object instanceof GroupInterface)) {
            $this->addErrorMessage(self::ERROR_WRONG_OBJECT);
        }

        if (!$this->hasError()) {
            $check = $this->groupManager->update($object);
            if ($check === true) {
                $this->addSuccessMessage(self::SUCCESS_SAVED);
            }
        }

        return $object;
    }
966024
public function itemCreate(Item $item)
    {
        $response = $this->getGuzzleClient()
            ->post(
                '/items',
                array_merge($this->setQuery(), $this->setBody($item))
            );

        return $this->serializer->deserialize(
            $response->getBody()->getContents(),
            Item::class,
            'json'
        );
    }
531095
public function put($key, $item)
    {
        $file = $this->filename($key);

        // json
        // text
        if (!file_put_contents($file, serialize($item))) {
            throw new \Exception(
                t("Failed writing cache object '!key'.", [
                    '!key' => $key
                ])
            );
        }
    }
1087882
public function updateItem($table, $item, $condition)
	{
        Eresus_Kernel::log(__METHOD__, LOG_NOTICE, 'This method is deprecated');
		$fields = $this->fields($table);
		if (!$table)
		{
			return false;
		}

		$q = Eresus_DB::getHandler()->createUpdateQuery();
		$q->update($table)
			->where($condition);

		foreach ($fields as $field)
		{
			if (isset($item[$field]))
			{
				$q->set($field, $q->bindValue($item[$field]));
			}
		}

        $q->execute();
		return true;
	}
183897
public function save(CacheItemInterface $item)
    {
        $this->cache->set($item->getKey(), $item);
        return $this->commit();
    }
805332
public function saveAuthItem($item,$oldName=null)
	{
		if($this->usingSqlite() && $oldName!==null && $item->getName()!==$oldName)
		{
			$this->db->createCommand()
				->update($this->itemChildTable, array(
					'parent'=>$item->getName(),
				), 'parent=:whereName', array(
					':whereName'=>$oldName,
				));
			$this->db->createCommand()
				->update($this->itemChildTable, array(
					'child'=>$item->getName(),
				), 'child=:whereName', array(
					':whereName'=>$oldName,
				));
			$this->db->createCommand()
				->update($this->assignmentTable, array(
					'itemname'=>$item->getName(),
				), 'itemname=:whereName', array(
					':whereName'=>$oldName,
				));
		}

		$this->db->createCommand()
			->update($this->itemTable, array(
				'name'=>$item->getName(),
				'type'=>$item->getType(),
				'description'=>$item->getDescription(),
				'bizrule'=>$item->getBizRule(),
				'data'=>serialize($item->getData()),
			), 'name=:whereName', array(
				':whereName'=>$oldName===null?$item->getName():$oldName,
			));
	}
1061267
public function save(CacheItemInterface $item)
    {
        $key = $item->getKey();

        $this->validateKey($key);

        $data = serialize($item);

        $result = file_put_contents($this->getPath($key), $data);

        if ($result === false) {
            return false;
        }

        return true;
    }
1268704
public function save($item, bool $update = false)
    {
        return Craft::$app->tags->saveTagGroup($item);
    }
777506
public function save($trace = false)
    {
        $retval = false;

        if ($this->isNew() && !$this->contains('nb_catalog_item_order')) {
            $last_sibling_id = $this->db->getQueryAsSingleField(
                'nb_catalog_item_id',
                'SELECT nb_catalog_item_id
                   FROM nb_catalog_item
                  WHERE nb_catalog_id=%cat_id$d
                    AND nb_catalog_item_level=1
                    AND nb_catalog_item_next_sibling IS NULL',
                array(
                    'cat_id' => $this->getCatalogId()
                )
            );
            $next_order = $this->db->getQueryAsSingleField(
                'next_order',
                'SELECT ifnull(next_order, def) + 1 AS next_order
                   FROM (SELECT max(nb_catalog_item_order) AS next_order, def
                           FROM nb_catalog_item ci1
                          RIGHT OUTER JOIN (SELECT 0 AS def FROM dual) ci2
                             ON nb_catalog_id=%cat_id$d
                        ) AS t',
                array(
                    'cat_id' => $this->getCatalogId()
                )
            );
            $this->setOrder($next_order);
            if ($retval = parent::save($trace)) {
                if (is_numeric($last_sibling_id)) {
                    $this->db->executeUpdate(
                        'UPDATE nb_catalog_item ci
                            SET ci.nb_catalog_item_next_sibling = %next_sibling$d
                          WHERE ci.nb_catalog_item_id=%item_id$d',
                        array(
                            'item_id' => $last_sibling_id,
                            'next_sibling' => $next_order
                        ), true
                    );
                }
            }
        } else {
            $retval = parent::save($trace);
        }

        return $retval;
    }
279472
public function save($reload = false, $no_triggers = false)
  {
    $m  = $this->getManager();
    $qb = $m->getQueryBuilder();
    $pk = $this->getPrimaryKey();

    if (!$no_triggers) {
      $this->beforeSave();
    }

    if ($this->isNew()) {
      $reload = true;

      $q = $qb->insert($this->getTable())
        ->setFromArray($this->getVarsForDB());
    } else {
      if (!$pk) {
        Exception::ThrowError(Exception::PK_NOT_SET, __CLASS__);
      }

      $q = $qb->update($this->getTable())
        ->setFromArray($this->getVarsForDB())
        ->where(array($pk => $this->get($pk)));
    }

    $m->query($q);

    if ($this->isNew()) {
      $id = $m->getConnection()->lastInsertId();

      $this->setIsNew(false);
      $this->set($pk, $id);
    }

    if ($reload && $pk) {
      $this->load();
    }

    if (!$no_triggers) {
      $this->afterSave();
    }

    return $this;
  }
73646
protected function updateItem(Model $item, $data)
    {
        $this->beforeAssignData($item, $data);
        $item->assign($data, null, $this->whitelistUpdate());
        $this->afterAssignData($item, $data);

        $this->beforeSave($item);
        $this->beforeUpdate($item);

        $success = $item->update();

        if ($success) {

            $this->afterUpdate($item);
            $this->afterSave($item);
        }

        return $success ? $item : null;
    }
997129
public function save($item, $autoUpdate = true)
    {
        $result = null;
        $this->allowSave = true;
        if (isset($this->events[ self::EVENT_ON_BEFORE_SAVE ])) {
            $this->secureEval($this->events[ self::EVENT_ON_BEFORE_SAVE ], array(
                'item' => &$item
            ));
        }
        if ($this->allowSave) {
            $result = $this->getDriver()->save($item, $autoUpdate);
        }

        if (isset($this->events[ self::EVENT_ON_AFTER_SAVE ])) {
            $this->secureEval($this->events[ self::EVENT_ON_AFTER_SAVE ], array(
                'item' => &$item
            ));
        }
        return $result;
    }
1234083
public function save(CacheItemInterface $item)
    {
        $expirationTime = null;

        if ($item instanceof ExtractableCacheLifetimeInterface) {
            $expirationTime = $item->getCacheLifetime();
        }

        return $this->cacheFrontend->save(
            serialize((
                $item instanceof ExtractableCacheValueInterface ?
                    $item->getCacheValue() :
                    $item->get()
            )),
            $this->prepareKey($item->getKey()),
            $this->tags,
            $expirationTime
        );
    }
639007
protected function flush($item, $delete = false)
    {
        // Create and open temporary file for writing
        $tmpFile = tempnam(sys_get_temp_dir(), uniqid() . '.tmp');
        $tempHandler = fopen($tmpFile, 'w');

        // Write headings
        fputcsv($tempHandler, $this->columns, $this->csvDelimiter);

        $identifier = $this->getIdentifier();
        $inserted = false;

        foreach ($this as $index => $row) {
            // Check an identifier; if equals and it doesn't need to delete - inserts new item
            if ($item[$identifier] == $row[$identifier]) {
                if (!$delete) {
                    $this->writeRow($tempHandler, $item);
                }
                // anyway marks row as inserted
                $inserted = true;
            } else {
                // Just it inserts row from source-file (copying)
                $this->writeRow($tempHandler, $row);
            }
        }

        // If the same item was not found and changed inserts the new item as the last row in the file
        if (!$inserted) {
            $this->writeRow($tempHandler, $item);
        }

        fclose($tempHandler);

        // Copies the original file to a temporary one.
        if (!copy($tmpFile, $this->filename)) {
            unlink($tmpFile);
            throw new DataStoreException("Failed to write the results to a file.");
        }

        unlink($tmpFile);
    }
1245747
public function save($key, $item, $ttl = null)
    {
        try {
            $this->handler->set($key, $item, $ttl);
        } catch (\Exception $e) {
            return $e->getMessage();
        }
        return true;
    }