StaticSchema
abstract class StaticSchema extends Schema (View source)
Schema implementation that provides the schema definition via static class properties.
Properties
static protected string | $model | ||
static protected string | $table | ||
static protected string[]|string | $primaryKey | ||
static protected string[] | $fields | ||
static protected array[] | $relationships |
Methods
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 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 28
string
getModel()
Returns the model class used to operate on the records from this schema.
at line 33
string
getTable()
Returns the name of the table for the schema.
at line 38
array
getPrimaryKey()
Returns a list fields that define the primary key for the schema.
at line 43
array
getFields()
Returns the list of fields for the schema.
at line 48
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.
Relationship
getRelationship(string $name)
Returns a single relationship with the given name.
Record
createRecordFromValues(array $values)
Returns a new record with the given values for the fields.
Record
createRecordFromRow(array $row, string $prefix = '')
Returns a new record with values taken from a result row with optional prefix for fields.