Schema
abstract class Schema (View source)
A schema for a database table.
Methods
Schema constructor.
Returns the model class used to operate on the records from this schema.
Returns the name of the table for the schema.
Returns a list fields that define the primary key for the schema.
Returns the list of fields for the schema.
Returns an associative list of relationship definitions for the schema.
Returns a list of all relationships for the schema.
Returns a single relationship with the given name.
Returns a new record with the given values for the fields.
Returns a new record with values taken from a result row with optional prefix for fields.
Returns a new model with a new record that has values from the given result row with optional relationships.
Details
at line 26
__construct(ContainerInterface $container)
Schema constructor.
at line 36
abstract string
getModel()
Returns the model class used to operate on the records from this schema.
at line 42
abstract string
getTable()
Returns the name of the table for the schema.
at line 48
abstract array
getPrimaryKey()
Returns a list fields that define the primary key for the schema.
at line 54
abstract array
getFields()
Returns the list of fields for the schema.
at line 75
abstract array
getRelationshipDefinitions()
Returns an associative list of relationship definitions for the schema.
The returned array is an associative array of definitions, where each key defines the name of the relationship.
Each definition must contain the following fields: - key : Defines the field (or list of fields) in the schema that references fields in the referenced schema - schema : Name of the schema in the container that the the relationship references - field : Defines the field (or list of fields) in the referenced schema - unique : If relationship can ever only refer to a single record (optional)
If the unique value is missing or even if it's defined as false
, the relationship will still be considered
unique if the referenced fields contain the entire primary key of the referenced schema (as it is not possible
to have multiple records with the same primary key).
Note that each relationship must have an appropriate reverse relationship defined in the referenced schema.
at line 81
array
getRelationships()
Returns a list of all relationships for the schema.
at line 98
Relationship
getRelationship(string $name)
Returns a single relationship with the given name.
at line 145
Record
createRecordFromValues(array $values)
Returns a new record with the given values for the fields.
at line 159
Record
createRecordFromRow(array $row, string $prefix = '')
Returns a new record with values taken from a result row with optional prefix for fields.