class Relationship (View source)

Represents a relationship between two schemas.

Methods

__construct(string $name, Schema $schema, array $fields, Schema $referencedSchema, array $referencedFields, bool $unique)

Relationship constructor.

string
getName()

Returns the name of the relationship.

getSchema()

Returns the referring schema.

array
getFields()

Returns the referring fields.

getReferencedSchema()

Returns the referenced schema.

array
getReferencedFields()

Returns referenced fields.

bool
isUniqueRelationship()

Tells if the relationship is unique or not.

getReverseRelationship()

Returns the reverse relationship.

void
fillRelationship(array $records, array $referencedRecords)

Fills this relationship for the given records from the list of given records.

void
fillSingleRecord(Record $record, Record $referencedRecord)

Fills this unique relationship for a single record.

Details

__construct(string $name, Schema $schema, array $fields, Schema $referencedSchema, array $referencedFields, bool $unique)

Relationship constructor.

Parameters

string $name Name of the relationship
Schema $schema The referring schema
array $fields The referring fields
Schema $referencedSchema The referenced schema
array $referencedFields The referenced fields
bool $unique Whether the relationship can only reference a single record or not

string getName()

Returns the name of the relationship.

Return Value

string Name of the relationship

Schema getSchema()

Returns the referring schema.

Return Value

Schema The referring schema

array getFields()

Returns the referring fields.

Return Value

array The referring fields

Schema getReferencedSchema()

Returns the referenced schema.

Return Value

Schema The referenced schema

array getReferencedFields()

Returns referenced fields.

Return Value

array The referenced fields

bool isUniqueRelationship()

Tells if the relationship is unique or not.

Return Value

bool True if the relationship can only refer to a single record, false otherwise

Relationship getReverseRelationship()

Returns the reverse relationship.

Return Value

Relationship The reverse relationship

void fillRelationship(array $records, array $referencedRecords)

Fills this relationship for the given records from the list of given records.

Parameters

array $records The records to fill
array $referencedRecords All the records referenced by the list of records to fill

Return Value

void

void fillSingleRecord(Record $record, Record $referencedRecord)

Fills this unique relationship for a single record.

Parameters

Record $record The record to fill
Record $referencedRecord The referenced record

Return Value

void