Nextcloud PHP API (master)

Id
in package

Read onlyYes
FinalYes

Attribute for marking a column as (part of) the primary key.

#[Entity(name: 'my_entity']
final class MyEntity {
    #[Id(generatorClass: ISnowflakeGenerator::class)]
    #[Column(name: 'id', type: ColumnType::Bigint)]
    public ?string $id = null;
}

Applying #[Id] to more than one property declares a composite primary key. In that case every id property must have its value set before calling insert() (via generatorClass, or assigned by the caller), since a composite key cannot rely on a single autoincrement column:

#[Entity(name: 'my_join_entity']
final class MyJoinEntity {
    #[Id]
    #[Column(name: 'left_id', type: ColumnType::Bigint)]
    public int $leftId;

    #[Id]
    #[Column(name: 'right_id', type: ColumnType::Bigint)]
    public int $rightId;
}
Tags
since
35.0.0
Attributes
#[Attribute]
\Attribute::TARGET_PROPERTY
#[Consumable]
$since: '35.0.0'

Table of Contents

Properties

$generatorClass  : ISnowflakeGenerator>|null

Methods

__construct()  : mixed

Properties

$generatorClass

public ISnowflakeGenerator>|null $generatorClass = null

Methods

__construct()

public __construct([string|null $generatorClass = null ]) : mixed
Parameters
$generatorClass : string|null = null
Tags
since
35.0.0
On this page

Search results