Nextcloud PHP API (master)

JoinColumn
in package

Read onlyYes
FinalYes

Attribute for mapping a property in an entity to a database column.

#[Entity(name: 'repository_customer')]
final class Customer {
    #[Id]
    #[Column(name: 'id', type: ColumnType::Bigint)]
    public ?int $id = null;

    #[OneToOne(targetEntity: Cart::class, mappedBy: 'customer')]
    #[JoinColumn(name: 'cart_id', referencedColumnName: 'id')]
    public ?Cart $cart = null;

    #[Column(name: 'name', type: Types::STRING, nullable: false)]
    public string $name;
}

#[Entity(name: 'repository_cart')]
final class Cart {
    #[Id]
    #[Column(name: 'id', type: ColumnType::Bigint)]
    public ?int $id = null;

    #[OneToOne(targetEntity: Customer::class, invertedBy: 'cart')]
    #[JoinColumn(name: 'customer_id', referencedColumnName: 'id')]
    public ?Customer $customer;
}
Tags
since
35.0.0
Attributes
#[Attribute]
\Attribute::TARGET_PROPERTY
#[Consumable]
$since: '35.0.0'

Table of Contents

Properties

$name  : non-empty-lowercase-string
$nullable  : bool
$onDelete  : "CASCADE"|null
$referencedColumnName  : non-empty-lowercase-string

Methods

__construct()  : mixed

Properties

$name

public non-empty-lowercase-string $name

The name of the column in the database.

$nullable

public bool $nullable = false

Whether the column is nullable in the database

$onDelete

public "CASCADE"|null $onDelete = null

The action what happen when deleting the foreign entity

$referencedColumnName

public non-empty-lowercase-string $referencedColumnName

The name of the column in the other table

Methods

__construct()

public __construct(string $name, string $referencedColumnName[, bool $nullable = false ][, string|null $onDelete = null ]) : mixed
Parameters
$name : string
$referencedColumnName : string
$nullable : bool = false
$onDelete : string|null = null
Tags
since
35.0.0
On this page

Search results