Nextcloud PHP API (master)

ManyToOne
in package

Read onlyYes
FinalYes

Attribute for mapping the owning side of a many-to-one relation: several rows of this entity can point at the same row of the target entity.

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

    #[ManyToOne(targetEntity: Customer::class)]
    #[JoinColumn(name: 'customer_id', referencedColumnName: 'id')]
    public Customer|null $customer = null;
}

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

Unlike OneToOne, the join column has no uniqueness constraint: several Order rows are allowed to reference the same Customer.

Tags
since
35.0.0
Attributes
#[Attribute]
\Attribute::TARGET_PROPERTY
#[Consumable]
$since: '35.0.0'

Table of Contents

Properties

$targetEntity  : class-string

Methods

__construct()  : mixed

Properties

$targetEntity

public class-string $targetEntity

Methods

__construct()

public __construct(string $targetEntity) : mixed
Parameters
$targetEntity : string
Tags
since
35.0.0
On this page

Search results