Save changes in target collection

@param string     $primaryValue Primary value from source entity
@param Connection $connection
@param Collection $collection   Target collection

@throws AssociationException
321865
public function saveChanges($primaryValue, Connection $connection, Collection $collection)
    {
        if ($collection->getEntityClass() !== $this->targetReflection->getClassName()) {
            throw new AssociationException(
                "Input collection should be type of "
                . $this->targetReflection->getClassName()
                . " but type of " . $collection->getEntityClass() . " given!"
            );
        }

        $changes = array_filter($collection->getChanges());
        if (empty($changes)) {
            return;
        }

        $sourceAdapter = $connection->getAdapter($this->sourceReflection->getAdapterName());
        $targetAdapter = $connection->getAdapter($this->targetReflection->getAdapterName());
        $mapper = $connection->getMapper();

        if (!$this->dominant) {
            $sourceAdapter = $targetAdapter;
        }

        // Unmap primary value
        $primaryValue = $mapper->unmapValue(
            $this->sourceReflection->getPrimaryProperty(),
            $primaryValue
        );

        $this->_saveAdd(
            $primaryValue,
            $sourceAdapter,
            $targetAdapter,
            $collection->getChanges(),
            $mapper
        );

        $this->_saveRemove(
            $primaryValue,
            $sourceAdapter,
            $targetAdapter,
            $collection->getChanges(),
            $mapper
        );
    }
387538
public function save(
        $table = null,
        Index $database = null,
        $primary = null
    ) {
        //argument test
        Argument::i()
            //Argument 1 must be a string or null
            ->test(1, 'string', 'null')
            //Argument 1 must be a string or null
            ->test(3, 'string', 'null');
        
        //if no table
        if (is_null($table)) {
            //if no default table either
            if (!$this->table) {
                //throw error
                Exception::i()->setMessage(Exception::TABLE_NOT_SET)->trigger();
            }
            
            $table = $this->table;
        }
        
        //if no database
        if (is_null($database)) {
            //and no default database
            if (!$this->database) {
                Exception::i()->setMessage(Exception::DATABASE_NOT_SET)->trigger();
            }
            
            $database = $this->database;
        }
        
        //get the meta data, the valid column values and whether is primary is set
        $meta = $this->getMeta($table, $database);
        
        if (is_null($primary)) {
            $primary = $meta[self::PRIMARY];
        }
        
        if (is_string($primary)) {
            $primary = array($primary);
        }
        
        $primarySet = $this->isPrimarySet($primary);
        
        //update original data
        $this->original = $this->data;
        
        //if no primary meta or primary values are not set
        if (empty($primary) || !$primarySet) {
            return $this->insert($table, $database);
        }
        
        return $this->update($table, $database, $primary);
    }
825857
protected function createTokensTable(Connection $connection, DatabaseSchemaInterface $schema): void
    {
        $manager = $connection->getSchemaManager();

        $table = new Table($schema->getTokensTable());
        $table->addColumn($schema->getTokensIdentityColumn(), Type::INTEGER)
            ->setNotnull(true)->setAutoincrement(true)->setUnsigned(true);
        $table->addColumn($schema->getTokensIsEnabledColumn(), Type::BOOLEAN)->setNotnull(true)->setDefault(true);
        $table->addColumn($schema->getTokensIsScopeModified(), Type::BOOLEAN)->setNotnull(true)->setDefault(false);
        $table->addColumn($schema->getTokensClientIdentityColumn(), Type::STRING)->setNotnull(true);
        $table->addColumn($schema->getTokensUserIdentityColumn(), Type::INTEGER)->setNotnull(false)->setUnsigned(true);
        $table->addColumn($schema->getTokensRedirectUriColumn(), Type::STRING)->setNotnull(false);
        $table->addColumn($schema->getTokensCodeColumn(), Type::STRING)->setNotnull(false);
        $table->addColumn($schema->getTokensTypeColumn(), Type::STRING)->setNotnull(false);
        $table->addColumn($schema->getTokensValueColumn(), Type::STRING)->setNotnull(false);
        $table->addColumn($schema->getTokensRefreshColumn(), Type::STRING)->setNotnull(false);
        $table->addColumn($schema->getTokensCodeCreatedAtColumn(), Type::DATETIME)->setNotnull(false);
        $table->addColumn($schema->getTokensValueCreatedAtColumn(), Type::DATETIME)->setNotnull(false);
        $table->addColumn($schema->getTokensRefreshCreatedAtColumn(), Type::DATETIME)->setNotnull(false);
        $table->setPrimaryKey([$schema->getTokensIdentityColumn()]);

        $table->addForeignKeyConstraint(
            $schema->getClientsTable(),
            [$schema->getTokensClientIdentityColumn()],
            [$schema->getClientsIdentityColumn()],
            $this->getOnDeleteCascadeConstraint()
        );

        $usersTable          = $schema->getUsersTable();
        $usersIdentityColumn = $schema->getUsersIdentityColumn();
        if ($usersTable !== null && $usersIdentityColumn !== null) {
            $table->addForeignKeyConstraint(
                $usersTable,
                [$schema->getTokensUserIdentityColumn()],
                [$usersIdentityColumn],
                $this->getOnDeleteCascadeConstraint()
            );
        }

        $manager->dropAndCreateTable($table);
    }
912533
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[GamecurrencyTableMap::COL_ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . GamecurrencyTableMap::COL_ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(GamecurrencyTableMap::COL_ID)) {
            $modifiedColumns[':p' . $index++]  = 'id';
        }
        if ($this->isColumnModified(GamecurrencyTableMap::COL_SENDERLOGIN)) {
            $modifiedColumns[':p' . $index++]  = 'senderLogin';
        }
        if ($this->isColumnModified(GamecurrencyTableMap::COL_RECEIVERLOGIN)) {
            $modifiedColumns[':p' . $index++]  = 'receiverLogin';
        }
        if ($this->isColumnModified(GamecurrencyTableMap::COL_TRANSACTIONID)) {
            $modifiedColumns[':p' . $index++]  = 'transactionId';
        }
        if ($this->isColumnModified(GamecurrencyTableMap::COL_BILLID)) {
            $modifiedColumns[':p' . $index++]  = 'billId';
        }
        if ($this->isColumnModified(GamecurrencyTableMap::COL_AMOUNT)) {
            $modifiedColumns[':p' . $index++]  = 'amount';
        }
        if ($this->isColumnModified(GamecurrencyTableMap::COL_MESSAGE)) {
            $modifiedColumns[':p' . $index++]  = 'message';
        }
        if ($this->isColumnModified(GamecurrencyTableMap::COL_STATUS)) {
            $modifiedColumns[':p' . $index++]  = 'status';
        }
        if ($this->isColumnModified(GamecurrencyTableMap::COL_DATETIME)) {
            $modifiedColumns[':p' . $index++]  = 'datetime';
        }

        $sql = sprintf(
            'INSERT INTO gamecurrency (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'id':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'senderLogin':
                        $stmt->bindValue($identifier, $this->senderlogin, PDO::PARAM_STR);
                        break;
                    case 'receiverLogin':
                        $stmt->bindValue($identifier, $this->receiverlogin, PDO::PARAM_STR);
                        break;
                    case 'transactionId':
                        $stmt->bindValue($identifier, $this->transactionid, PDO::PARAM_INT);
                        break;
                    case 'billId':
                        $stmt->bindValue($identifier, $this->billid, PDO::PARAM_INT);
                        break;
                    case 'amount':
                        $stmt->bindValue($identifier, $this->amount, PDO::PARAM_INT);
                        break;
                    case 'message':
                        $stmt->bindValue($identifier, $this->message, PDO::PARAM_STR);
                        break;
                    case 'status':
                        $stmt->bindValue($identifier, $this->status, PDO::PARAM_INT);
                        break;
                    case 'datetime':
                        $stmt->bindValue($identifier, $this->datetime ? $this->datetime->format("Y-m-d H:i:s.u") : null, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
305775
public function createCollection(array &$data = null, $primaryId = null) {
		$collectionClass = $this->getCollectionClass();
		$modelClass      = $this->getModelClass();
		
		if ($primaryId === null) {
			$primaryId = $this->getPrimaryName();
		}

		// Primary ID data handling
		if (! empty($data) || $primaryId !== null) {
			$validation = true;

			array_walk($data, function(&$item) use($primaryId, &$validation) {
				if (! isset($item[$primaryId])) {
					$validation = false;
				}
			});

			if ($validation) {
				array_walk($data, function(&$item) use($primaryId) {
					if (is_object($item[$primaryId])) {
						$item[$primaryId] = (string) $item[$primaryId];
					}
				});
			} else {
				$primaryId = null;
			}
		}

		// Creating and supplying of the dependencies
		$collection = $collectionClass::factory($data, $modelClass, $primaryId);
		$collection->setDatagate($this);

		if ($this->hasLocator()) {
			$collection->setLocator($this->getLocator());
		}

		return $collection;
	}
99135
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[DealerTableMap::ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . DealerTableMap::ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(DealerTableMap::ID)) {
            $modifiedColumns[':p' . $index++]  = 'ID';
        }
        if ($this->isColumnModified(DealerTableMap::VISIBLE)) {
            $modifiedColumns[':p' . $index++]  = 'VISIBLE';
        }
        if ($this->isColumnModified(DealerTableMap::ADDRESS1)) {
            $modifiedColumns[':p' . $index++]  = 'ADDRESS1';
        }
        if ($this->isColumnModified(DealerTableMap::ADDRESS2)) {
            $modifiedColumns[':p' . $index++]  = 'ADDRESS2';
        }
        if ($this->isColumnModified(DealerTableMap::ADDRESS3)) {
            $modifiedColumns[':p' . $index++]  = 'ADDRESS3';
        }
        if ($this->isColumnModified(DealerTableMap::ZIPCODE)) {
            $modifiedColumns[':p' . $index++]  = 'ZIPCODE';
        }
        if ($this->isColumnModified(DealerTableMap::CITY)) {
            $modifiedColumns[':p' . $index++]  = 'CITY';
        }
        if ($this->isColumnModified(DealerTableMap::COUNTRY_ID)) {
            $modifiedColumns[':p' . $index++]  = 'COUNTRY_ID';
        }
        if ($this->isColumnModified(DealerTableMap::LATITUDE)) {
            $modifiedColumns[':p' . $index++]  = 'LATITUDE';
        }
        if ($this->isColumnModified(DealerTableMap::LONGITUDE)) {
            $modifiedColumns[':p' . $index++]  = 'LONGITUDE';
        }
        if ($this->isColumnModified(DealerTableMap::CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'CREATED_AT';
        }
        if ($this->isColumnModified(DealerTableMap::UPDATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'UPDATED_AT';
        }
        if ($this->isColumnModified(DealerTableMap::VERSION)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION';
        }
        if ($this->isColumnModified(DealerTableMap::VERSION_CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_AT';
        }
        if ($this->isColumnModified(DealerTableMap::VERSION_CREATED_BY)) {
            $modifiedColumns[':p' . $index++]  = 'VERSION_CREATED_BY';
        }

        $sql = sprintf(
            'INSERT INTO dealer (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'ID':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'VISIBLE':
                        $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
                        break;
                    case 'ADDRESS1':
                        $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR);
                        break;
                    case 'ADDRESS2':
                        $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR);
                        break;
                    case 'ADDRESS3':
                        $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR);
                        break;
                    case 'ZIPCODE':
                        $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR);
                        break;
                    case 'CITY':
                        $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
                        break;
                    case 'COUNTRY_ID':
                        $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
                        break;
                    case 'LATITUDE':
                        $stmt->bindValue($identifier, $this->latitude, PDO::PARAM_STR);
                        break;
                    case 'LONGITUDE':
                        $stmt->bindValue($identifier, $this->longitude, PDO::PARAM_STR);
                        break;
                    case 'CREATED_AT':
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'UPDATED_AT':
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION':
                        $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
                        break;
                    case 'VERSION_CREATED_AT':
                        $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'VERSION_CREATED_BY':
                        $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
285052
protected function insertBelongsToMany($recordName, Relation $relation, $columnValue)
    {
        $joinTable = $relation->getTable();
        $this->tables[] = $joinTable;
        $relatedRecords = explode(',', str_replace(', ', ',', $columnValue));

        foreach ($relatedRecords as $relatedRecord) {
            list($fields, $values) = $this->buildBelongsToManyRecord($recordName, $relation, $relatedRecord);
            $placeholders = rtrim(str_repeat('?, ', count($values)), ', ');
            $sql = "INSERT INTO $joinTable ($fields) VALUES ($placeholders)";
            $sth = $this->db->prepare($sql);
            $sth->execute($values);
        }
    }
91303
protected function insertRelatedRecords($recordName, Model $record, $camelKey, $columnValue)
    {
        $relation = $record->$camelKey();

        if ($relation instanceof BelongsTo) {
            $this->insertBelongsTo($record, $relation, $columnValue);

            return;
        }

        if ($relation instanceof BelongsToMany) {
            $this->insertBelongsToMany($recordName, $relation, $columnValue);

            return;
        }
    }
1025763
protected function createBelongsToManyRelationship(
        $primaryKey,
        iterable $foreignKeys,
        string $intTableName,
        string $intPrimaryKeyName,
        string $intForeignKeyName
    ): void {
        assert(is_string($primaryKey) === true || is_int($primaryKey) === true);

        try {
            $this->inTransaction(function () use (
                $intTableName,
                $intPrimaryKeyName,
                $intForeignKeyName,
                $primaryKey,
                $foreignKeys
            ): void {
                $connection = $this->getConnection();
                $query      = $connection->createQueryBuilder();

                $query->insert($intTableName)->values([$intPrimaryKeyName => '?', $intForeignKeyName => '?']);
                $statement = $connection->prepare($query->getSQL());

                foreach ($foreignKeys as $value) {
                    assert(is_string($value) === true || is_int($value) === true);
                    $statement->bindValue(1, $primaryKey);
                    $statement->bindValue(2, $value);
                    $statement->execute();
                }
            });
        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (DBALException $exception) {
            $message = 'Belongs-to-Many relationship creation failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
749125
public function findPrimaries(array $primaryValues, array $associate = [])
    {
        $reflection = Entity\Reflection::load($this->getEntityName());

        if (!$reflection->hasPrimary()) {
            throw new Exception\RepositoryException(
                "Method can not be used because entity " . $this->getEntityName()
                . " has no primary property defined!"
            );
        }

        if (empty($primaryValues)) {
            throw new Exception\RepositoryException(
                "Values can not be empty!"
            );
        }

        try {

            return $this->query()
                ->select()
                ->setFilter(
                    [
                        $reflection->getPrimaryProperty()->getName() => [
                            Filter::EQUAL => $primaryValues
                        ]
                    ]
                )
                ->associate($associate)
                ->run($this->connection);
        } catch (Exception\QueryException $e) {
            throw new Exception\RepositoryException($e->getMessage());
        }
    }
640202
public function setConnection(Connection $connection)
    {
        if (! in_array($connection, $this->_connections, true)) {
            $this->_connections[] = $connection;
        }
    }
851134
public static function selectPrimaryKey(Connection $connection, $primary_key)
    {
        return static::selectOne($connection)
            ->where(static::$primary_key, $primary_key)
            ->execute();
    }
131865
private function addInToManyRelationship(
        Connection $connection,
        string $primaryIdentity,
        string $name,
        iterable $secondaryIdentities,
        Closure $builderHook
    ): int {
        $inserted = 0;

        $secondaryIdBindName = ':secondaryId';
        $saveToMany          = $this
            ->createBuilderFromConnection($connection, $this->getModelClass())
            ->prepareCreateInToManyRelationship($name, $primaryIdentity, $secondaryIdBindName);

        $saveToMany = call_user_func($builderHook, $name, $saveToMany);

        foreach ($secondaryIdentities as $secondaryId) {
            try {
                $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
            } /** @noinspection PhpRedundantCatchClauseInspection */ catch (UcvException $exception) {
                // Spec: If all of the specified resources can be added to, or are already present in,
                // the relationship then the server MUST return a successful response.
                //
                // Currently DBAL cannot do insert or update in the same request.
                // https://github.com/doctrine/dbal/issues/1320
                continue;
            }
        }

        return $inserted;
    }
528684
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[CategoryTableMap::COL_ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryTableMap::COL_ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(CategoryTableMap::COL_ID)) {
            $modifiedColumns[':p' . $index++]  = 'id';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_SOURCE_ID)) {
            $modifiedColumns[':p' . $index++]  = 'source_id';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_PAGEID)) {
            $modifiedColumns[':p' . $index++]  = 'pageid';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_TITLE)) {
            $modifiedColumns[':p' . $index++]  = 'title';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_FILES)) {
            $modifiedColumns[':p' . $index++]  = 'files';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_SUBCATS)) {
            $modifiedColumns[':p' . $index++]  = 'subcats';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_PAGES)) {
            $modifiedColumns[':p' . $index++]  = 'pages';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_SIZE)) {
            $modifiedColumns[':p' . $index++]  = 'size';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_HIDDEN)) {
            $modifiedColumns[':p' . $index++]  = 'hidden';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'created_at';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_UPDATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'updated_at';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_TREE_LEFT)) {
            $modifiedColumns[':p' . $index++]  = 'tree_left';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_TREE_RIGHT)) {
            $modifiedColumns[':p' . $index++]  = 'tree_right';
        }
        if ($this->isColumnModified(CategoryTableMap::COL_TREE_LEVEL)) {
            $modifiedColumns[':p' . $index++]  = 'tree_level';
        }

        $sql = sprintf(
            'INSERT INTO category (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'id':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'source_id':
                        $stmt->bindValue($identifier, $this->source_id, PDO::PARAM_INT);
                        break;
                    case 'pageid':
                        $stmt->bindValue($identifier, $this->pageid, PDO::PARAM_INT);
                        break;
                    case 'title':
                        $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
                        break;
                    case 'files':
                        $stmt->bindValue($identifier, $this->files, PDO::PARAM_INT);
                        break;
                    case 'subcats':
                        $stmt->bindValue($identifier, $this->subcats, PDO::PARAM_INT);
                        break;
                    case 'pages':
                        $stmt->bindValue($identifier, $this->pages, PDO::PARAM_INT);
                        break;
                    case 'size':
                        $stmt->bindValue($identifier, $this->size, PDO::PARAM_INT);
                        break;
                    case 'hidden':
                        $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_BOOL);
                        break;
                    case 'created_at':
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s.u") : null, PDO::PARAM_STR);
                        break;
                    case 'updated_at':
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s.u") : null, PDO::PARAM_STR);
                        break;
                    case 'tree_left':
                        $stmt->bindValue($identifier, $this->tree_left, PDO::PARAM_INT);
                        break;
                    case 'tree_right':
                        $stmt->bindValue($identifier, $this->tree_right, PDO::PARAM_INT);
                        break;
                    case 'tree_level':
                        $stmt->bindValue($identifier, $this->tree_level, PDO::PARAM_INT);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
522192
public function update($primaryKeyValue, $fieldsValues)
    {
        $this->connectToDB();
        $this->queryBuilder->table($this->table());
        $this->primaryKeyWhere($primaryKeyValue);
        $this->queryBuilder->update($fieldsValues);
        return $primaryKeyValue;
    }
953293
protected function doInsert(ConnectionInterface $con)
    {
        $modifiedColumns = array();
        $index = 0;

        $this->modifiedColumns[AttributeTypeAvMetaTableMap::ID] = true;
        if (null !== $this->id) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeTypeAvMetaTableMap::ID . ')');
        }

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(AttributeTypeAvMetaTableMap::ID)) {
            $modifiedColumns[':p' . $index++]  = 'ID';
        }
        if ($this->isColumnModified(AttributeTypeAvMetaTableMap::ATTRIBUTE_AV_ID)) {
            $modifiedColumns[':p' . $index++]  = 'ATTRIBUTE_AV_ID';
        }
        if ($this->isColumnModified(AttributeTypeAvMetaTableMap::ATTRIBUTE_ATTRIBUTE_TYPE_ID)) {
            $modifiedColumns[':p' . $index++]  = 'ATTRIBUTE_ATTRIBUTE_TYPE_ID';
        }
        if ($this->isColumnModified(AttributeTypeAvMetaTableMap::LOCALE)) {
            $modifiedColumns[':p' . $index++]  = 'LOCALE';
        }
        if ($this->isColumnModified(AttributeTypeAvMetaTableMap::VALUE)) {
            $modifiedColumns[':p' . $index++]  = 'VALUE';
        }
        if ($this->isColumnModified(AttributeTypeAvMetaTableMap::CREATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'CREATED_AT';
        }
        if ($this->isColumnModified(AttributeTypeAvMetaTableMap::UPDATED_AT)) {
            $modifiedColumns[':p' . $index++]  = 'UPDATED_AT';
        }

        $sql = sprintf(
            'INSERT INTO attribute_type_av_meta (%s) VALUES (%s)',
            implode(', ', $modifiedColumns),
            implode(', ', array_keys($modifiedColumns))
        );

        try {
            $stmt = $con->prepare($sql);
            foreach ($modifiedColumns as $identifier => $columnName) {
                switch ($columnName) {
                    case 'ID':
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
                        break;
                    case 'ATTRIBUTE_AV_ID':
                        $stmt->bindValue($identifier, $this->attribute_av_id, PDO::PARAM_INT);
                        break;
                    case 'ATTRIBUTE_ATTRIBUTE_TYPE_ID':
                        $stmt->bindValue($identifier, $this->attribute_attribute_type_id, PDO::PARAM_INT);
                        break;
                    case 'LOCALE':
                        $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
                        break;
                    case 'VALUE':
                        $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
                        break;
                    case 'CREATED_AT':
                        $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                    case 'UPDATED_AT':
                        $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
                        break;
                }
            }
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
        }

        try {
            $pk = $con->lastInsertId();
        } catch (Exception $e) {
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
        }
        $this->setId($pk);

        $this->setNew(false);
    }
30399
public function updateField($primaryKey, $field, $value = null): bool
    {
        $query = $this->query()
            ->update()
            ->set([
                $field => $value,
            ])
            ->where([
                $this->primaryKey() => $primaryKey,
            ]);

        $statement = $query->execute();
        $success = $statement->rowCount() > 0;
        $statement->closeCursor();

        return $success;
    }