Set the given field as the primary key.

@param  PropertyField $field The new ID field.
@param  IdProperty    $prop  The new ID property.
@return self
559345
private function applyPrimaryKey(PropertyField $field, IdProperty $prop)
    {
        unset($prop);

        $model  = $this->targetModel();
        $source = $model->source();

        $sql = strtr(
            'ALTER TABLE `%table` ADD PRIMARY KEY (`%key`)',
            [
                '%table' => $source->table(),
                '%key'   => $field->ident(),
            ]
        );
        $source->db()->query($sql);

        return $this;
    }
485711
protected function setDomainObjectInProperty($object, $propertyName, $domainObject, $lastObject, array $objectArrayPropertyPath)
    {
        if (is_object($object)) {
            ObjectAccess::setProperty($object, $propertyName, $domainObject);
        } elseif (is_array($object)) {
            $this->injectDomainObjectInLastObject($domainObject, $lastObject, $objectArrayPropertyPath);
        }
    }
220491
private function field($array, $prop = null) {
        if (is_string($array)) {
            $prop = $array;
            $array = $_POST;
        }

        if (!isset($array[$prop])) {
            return null;
        }

        return $array[$prop];
    }
883561
public function setPrimaryKeyType(int $idType): self
    {
        switch ($idType) {
            case 1:
                return $this->setPrimaryKeyFieldTrait(IdFieldTrait::class);
            case 4:
                return $this->setPrimaryKeyFieldTrait(NonBinaryUuidFieldTrait::class);
            case 8:
                return $this->setPrimaryKeyFieldTrait(UuidFieldTrait::class);
            default:
                throw new \LogicException('Unknown trait selected');
        }
    }
423426
protected function labelFromProp(IdProperty $prop)
    {
        $mode = $prop->mode();
        switch ($mode) {
            case IdProperty::MODE_AUTO_INCREMENT:
                return 'auto-increment ID';

            case IdProperty::MODE_CUSTOM:
                return 'custom ID';

            default:
                $label = $this->labelFromMode($mode);
                if ($label) {
                    return sprintf('auto-generated ID (%s)', $label);
                } else {
                    return 'auto-generated ID';
                }
        }

        return null;
    }
210048
public function addField(Field $field)
    {
        $tmp               = $this->fields->getValue($this->entity);
        $tmp[$field->name] = $field;
        $this->fields->setValue($this->entity, $tmp);

        if ($field->role == 'id') {
            $key = new \ReflectionProperty(Entity::class, 'key');
            $key->setAccessible(true);
            $key->setValue($this->entity, $field->name);
        }
    }
780722
public function setIdentityProperty($property)
    {
        $this->_identity_property = null;

        if (is_string($property)) {
            $property = $this->getProperty($property);
        }

        if ($property) {
            //an identitying property can be used as
            //an identifying property
            $this->addIdentifyingProperty($property);

            //don't allow direct write
            $property->setWriteAccess(AnDomain::ACCESS_PRIVATE);

            $this->_identity_property = $property;
        }

        return $this;
    }
1075063
protected void handleAddProperty(EntityBuilder builder, String propName, Field currentField, Object obj) {
        builder.addProperty(propName, ReflectionUtils.getFieldValue(currentField, obj));
    }
1362092
public function set($prop, $value) {
        $class = get_class($this);
        if(property_exists($class, $prop)) {
            // Use reflection to set private property
            $reflection = new \ReflectionProperty($class, $prop);
            $reflection->setAccessible(true);
            $reflection->setValue($this, $value);
        } else {
            $msg = sprintf("Unexpected data set `%s` on `%s`", $prop, $class);
            throw new ContextException($msg);
        }
        
        return $this;
    }
1314379
function setDNProp($propName, $propValue, $type = 'utf8String')
    {
        if (empty($this->dn)) {
            $this->dn = array('rdnSequence' => array());
        }

        if (($propName = $this->_translateDNProp($propName)) === false) {
            return false;
        }

        foreach ((array) $propValue as $v) {
            if (!is_array($v) && isset($type)) {
                $v = array($type => $v);
            }
            $this->dn['rdnSequence'][] = array(
                array(
                    'type' => $propName,
                    'value'=> $v
                )
            );
        }

        return true;
    }
1170575
public static function setField($owningEntity, $key, CustomFieldBase $entity)
    {
        if ($entity->isEmpty()) {
            self::remove($owningEntity, $key);

            return;
        }
        /** @var Collection */
        $customFields = $owningEntity->getNonemptyCustomFields();
        if ($entity->getFieldId() !== $key) {
            $entity = clone $entity;
            $entity->setFieldId($key);
        }
        $customFields->set($key, $entity);
    }
1208982
public function setProperty(PropertyInterface $property)
    {
        $this->property      = $property;
        $this->propertyType  = $property->type();
        $this->propertyIdent = $property->ident();

        $inputType = $property['input_type'];
        if ($inputType) {
            $this->inputType = $inputType;
        }

        $displayType = $property['display_type'];
        if ($displayType) {
            $this->displayType = $displayType;
        }

        return $this;
    }
1357093
public static void setId(Object entity, EntityMetadata metadata, Object rowKey)
    {
        try
        {
            Field idField = (Field) metadata.getIdAttribute().getJavaMember();
            set(entity, idField, rowKey);
        }
        catch (IllegalArgumentException iarg)
        {
            throw new PropertyAccessException(iarg);
        }
    }
717296
protected function resolveFieldIsList($prop): ?bool
    {
        /** @var Annotation\Field $annotationField */
        $annotationField = $this->getFieldAnnotation($prop, Annotation\Field::class);
        if ($annotationField && $annotationField->type) {
            return TypeUtil::isTypeList($annotationField->type);
        }

        return null;
    }
1120168
protected function doInsert(PropelPDO $con)
    {
        $modifiedColumns = array();
        $index = 0;

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

         // check the columns in natural order for more readable SQL queries
        if ($this->isColumnModified(RolePeer::ID)) {
            $modifiedColumns[':p' . $index++]  = '`id`';
        }
        if ($this->isColumnModified(RolePeer::NAME)) {
            $modifiedColumns[':p' . $index++]  = '`name`';
        }
        if ($this->isColumnModified(RolePeer::ROLE)) {
            $modifiedColumns[':p' . $index++]  = '`role`';
        }

        $sql = sprintf(
            'INSERT INTO `role` (%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 '`name`':
                        $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
                        break;
                    case '`role`':
                        $stmt->bindValue($identifier, $this->role, 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), $e);
        }

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

        $this->setNew(false);
    }
180074
def get_fields_with_prop(cls, prop_key):
        

        ret = []

        for key, val in getattr(cls, '_fields').items():
            if hasattr(val, prop_key):
                ret.append((key, getattr(val, prop_key)))
        return ret
49680
private void setField(Row row, Table schemaTable, Object embeddedObject, Attribute embeddedAttrib)
    {
        Field field = (Field) embeddedAttrib.getJavaMember();
        FieldDef fieldDef = schemaTable.getField(((AbstractAttribute) embeddedAttrib).getJPAColumnName());

        Object valueObj = PropertyAccessorHelper.getObject(embeddedObject, field);

        if (valueObj != null)
            NoSqlDBUtils.add(fieldDef, row, valueObj, ((AbstractAttribute) embeddedAttrib).getJPAColumnName());

    }