The Cycle ORM relies on the Schema instance to define its behavior. All of the entity fields, relations, and options are located in such a schema and must be pre-calculated prior to runtime usage. In fact, schema operates as a nested hash table providing quick access to each of the definition.
To access the schema from an initiated ORM instance, use the method
// print the table associated with the entity
You can create a new ORM instance with an altered schema using
$orm2 = $orm->withSchema(new \Cycle\ORM\Schema([...]));
The original ORM instance won't be affected.
Most of the schema properties are intended for internal use. However, accessing them might give your application the ability to configure the environment (for example automatic binding to Container).
All schema properties are available as public constants on class
|Unique entity name (can be omitted when schema supplied in [role => schema] form).
|Class name to represent the entity can be null if an alternative mapper implementation is used.
|Class to hydrate and extract data from entities and initiate command chains. Defaults to
|Class to represent gateway object to entity database and table. Defaults to
|Class to aggregate all entity select operations. Defaults to
|Database name associated with an entity. Defaults to
null (default database).
|Table name associated with the entity.
|Property used to represent an entity's primary key.
|List of fields used to reference entity by other entity relations used to speed up memory lookup. Automatically generated.
|Associative array of field names assigned with the table column name.
|List of relations assigned to the given entity, see below.
|List of classes which extends given entity class. Used for Single Table Inheritance.
|Class name to represent the scope applied to all entity queries. Defaults to none.
|Associated array of fields with assigned typecast functions.
|Optional section, reserved for custom mapper implementations.
Each entity might have none or multiple relations associated with it. Each relation association must follow the given schema.
|Relation type, driven by
|Target entity role.
|Relation specific options, see below.
Relation options include:
|Indicates that relation must be automatically saved with a parent entity. Defaults to
|Indicates that relation can point to null. User-driven.
|Outer entity field name.
|Inner (parent) entity field name.
|Morphed relations only. Name of the morphed field. Autogenerated.
|For collection relations only. Additional where query to filter related entities by. Supports compound queries.
|Points to the inner key of source (parent) entity in pivot (though) entity.
|Points to the outer key of related entity in pivot (though) entity.
|Thought entity role name.
|Additional where conditions added for related entities.
The ORM Schema can be serialized in order to cache it and avoid calculations on each request. Cycle encourages schema compilation in the background (see cycle/schema-builder).