INSERT, straightforward UPDATE

@param EntityMetadata $entity
@param array $options

@return TokenSequencer
975618
public function save(EntityMetadata $entity, array $options = [])
    {
        return new TokenSequencer($this->tokenFactory, self::TYPE_SAVE, $entity, $options);
    }
1371269
protected function insertRow(AbstractEntity $entity)
    {
        $values  = $entity->getDbValues();
        $columns = array_keys($values);

        if ($this->autoIncrementColumn && ! array_key_exists($this->autoIncrementColumn, $values)) {
            throw new LogicException('auto_increment column ' . $this->autoIncrementColumn . ' not found');
        }

        $query = $this->getSqlObject()
            ->insert()
            ->columns($columns)
            ->values($values);

        $statement = $this->getSqlObject()->prepareStatementForSqlObject($query);
        $result    = $statement->execute();

        if ($this->autoIncrementColumn && ! $values[$this->autoIncrementColumn]) {
            $entity->exchangeArray([
                $this->autoIncrementColumn => $result->getGeneratedValue()
            ]);
        }
    }
588454
public function insert($entity)
    {
        $entity->set($this->_property, $this->getRoot());

        //only add the entity into the entityset if it has
        //already been loaded
        //otherwise don't
        if ($this->getObject()->isLoaded()) {
            $this->getObject()->insert($entity);
        }

        return $entity;
    }
976426
public function execute($entity, $method = 'get', $options = [])
    {

        $this->cleanQueryParams($entity);
        $configuration = $this->_getEntityConfiguration($entity);

        if ($method != 'get'){
            foreach ($configuration->attributes as $key => $attribute) {
                $this->validateAttribute($entity, $key, ['required']);
            } 
        }

        $this->processOptions($options, $configuration);

        $this->_setDefaultHeaders($configuration->query);
        $this->_setCustomHeaders($entity, $configuration->query);
        //$this->_setIdempotencyHeader($configuration->query, $configuration, $method);
        $this->setQueryParams($entity);
        
        return $this->_client->{$method}($configuration->url, $configuration->query);
    }
111485
public function beforeSave(Event $event, $entity, $options)
    {
        $newPassword = $entity->get('new_password');

        if (!empty($newPassword)) {
            $entity->set('password', $entity->new_password); // set for password-changes
        }

        if ($entity->isNew()) {
            if ($entity->get('active') !== 1) {
                $entity->set('request_key', $this->generateRequestKey());
            }
        }
    }
1023312
public static function updateEntityFromArray($entity, array $data)
    {
        foreach ($data as $field => $value) {
            $method = 'set' . self::formatStringToMethodName($field);
            if (method_exists($entity, $method)) {
                $entity->$method($value);
            }
        }

        return $entity;
    }
1307002
private function executeInserts($class, array $options = array())
    {
        $className = $class->name;
        $persister = $this->getXmlEntityPersister($className);

        $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postPersist]);
        $hasListeners = $this->evm->hasListeners(Events::postPersist);
        if ($hasLifecycleCallbacks || $hasListeners) {
            $documents = array();
        }

        $inserts = array();
        foreach ($this->entityInsertions as $oid => $xmlEntity) {
            if (get_class($xmlEntity) === $className) {
                $persister->insert($xmlEntity);
                unset($this->entityInsertions[$oid]);
            }
        }
    }
451615
public function UpdateEntityType(\Google\Cloud\Dialogflow\V2\UpdateEntityTypeRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.cloud.dialogflow.v2.EntityTypes/UpdateEntityType',
        $argument,
        ['\Google\Cloud\Dialogflow\V2\EntityType', 'decode'],
        $metadata, $options);
    }
175792
protected function updateRow(AbstractEntity $entity)
    {
        $values = $entity->getDbValues();

        $query = $this->getSqlObject()
            ->update()
            ->set($values)
            ->where($this->getPrimaryKeyWheres($entity));

        $this->execute($query);
    }
599094
public function insert($entity)
    {
        $persistor = new CsvPersistor(
            $this->gateway,
            $this->table,
            $this->entityRegistry->getEntityBuilder(),
            $this->entityRegistry
        );
        $persistor->insert($entity);
    }
1255451
public function pushData(Entity $entity)
    {
        if ($this->isMany()) {
            $this->primaryData[] = $entity;
            return $this;
        }
        $this->primaryData = $entity;
        return $this;
    }
1091028
protected function updateInDatabase(Entity $entity)
    {
        $primaryKey = $this->mapper->getPrimaryKey($this->getTable());
        $values = $entity->getModifiedRowData();
        return $this->connection->query(
            'UPDATE %n SET %a WHERE %n = ?',
            $this->getTable(),
            $values,
            $primaryKey,
            $this->getIdValue($entity)
        );
    }
1075048
protected function persistEntity(EntityInterface $entity, array $data, array $options = []) : ?Response
    {
        $table = $this->loadModel();
        Assert::isInstanceOf($table, Table::class);

        $options = array_merge($options, ['lookup' => true]);
        $entity = $table->patchEntity($entity, $data, $options);

        $saved = false;
        try {
            $saved = $table->save($entity);
        } catch (PDOException $e) {
            Log::error($e->getMessage());
        }

        if ($entity->getErrors()) {
            Log::warning((string)json_encode($entity->getErrors()));
        }

        if (! $saved) {
            $this->Flash->error((string)__('The record could not be saved, please try again.'));
        }

        if ($saved) {
            $this->Flash->success((string)__('The record has been saved.'));

            $primaryKey = $table->getPrimaryKey();
            if (! is_string($primaryKey)) {
                throw new UnsupportedPrimaryKeyException();
            }

            // handle file uploads if found in the request data
            $fileUpload = new FileUpload($table);
            $fileUpload->link(
                $entity->get($primaryKey),
                (array)$this->request->getData()
            );

            $url = [];
            if ($table instanceof Table) {
                $url = $table->getParentRedirectUrl($table, $entity);
            }
            $url = ! empty($url) ? $url : ['action' => 'view', $entity->get($primaryKey)];

            return $this->redirect($url);
        }

        return null;
    }
865322
public function beforeSave($event, $entity, $options)
    {
        if (!empty($entity->new_password)) {
            $entity->password = $entity->new_password; // set for password-changes
        }
    }
639545
protected function _insertParent($entity) {
		extract($this->_config);
		$parent = $this->_getById($entity->$parent);
		if ($parent) {
			$r = $parent->$right;
			$this->_update($r, '+', 2, $this->_scope($entity));
			$entity->set([
				$left => $r,
				$right => $r + 1
			]);
		}
	}
1079900
public function update(EntityContract $entity, Bag $parameters)
    {
        if (is_object($parameters->get($this->name)) || is_array($parameters->get($this->name))) {
            $parameters->set($this->name, Yaml::dump($parameters));
        }

        return parent::update($entity, $parameters);
    }
258058
public function slug(EntityInterface $entity, array $options = []) {
		$overwrite = isset($options['overwrite']) ? $options['overwrite'] : $this->_config['overwrite'];
		if (!$overwrite && $entity->get($this->_config['overwriteField'])) {
			$overwrite = true;
		}
		if ($overwrite || $entity->isNew() || !$entity->get($this->_config['field'])) {
			$slug = [];
			foreach ((array)$this->_config['label'] as $v) {
				$v = $entity->get($v);
				if ($v !== null && $v !== '') {
					$slug[] = $v;
				}
			}
			$slug = implode($slug, $this->_config['separator']);
			$slug = $this->generateSlug($slug, $entity);
			$entity->set($this->_config['field'], $slug);
		}
	}