Model configuration
The Object Relational Mapping (ORM) pattern is based on the mapping between tables and classes and Porte make no exception.
Simply said, tables in the database are accessed by a type name in Porte and each type is associated with a table model. In this table model we defined table related configurations as well as the fields present in the database table. Fields in the table are accessed by a property name and each property is associated with a property model.
This is simply said because for exemple properties are not always present in the database (we call them transient fields) and may be made of two fields (like with geo point properties).
Defining a model
There exists one model per type of record. When a new type of record is initialized, Porte will look for its configuration, sanitize the configuration and create a new model instance. The result is then cached and made accessible to everyone throw the "$porte->models" property.
There exists differents strategy to define your model and you could quite easily create your own.
Accessing a model
Models can be accessed from instance of "PorteConnection", "PorteTable", "PorteRecords" and "PorteIterator".
- From a connection
"$connection->getModel($record)"
"$connection->models->{$type} - From a table
"$table->model" - From a record
"$record->model" - From a list
"$list->model"