Model configuration
In Porte, the Object Relational Mapping (ORM) pattern is based on the mapping between tables and classes.
Each type of record, stored as a table in a database, is associated to a table model and identified by a property "type". Model configuration is done at class level through the configuration of two properties with array type: "meta_table" and "meta_fields".
-
Table configuration
Configure a given type of record at a table / class level. -
Fields configuration
Configure a given type of record at a field / attribute level.
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 and create a new model instance. The result is than cached in the connection object.
Accessing a model
Models can be accessed from instance of "PorteConnection", "PorteTable", "PorteRecords" and "PorteIterator".
-
From a connection
"$connection->getModel($record)"
"$connection->getTable($record)->model"
"$connection->{record_type}->model"
-
From a table
"$table->model" -
From a record
"$record->model" -
From a list
"$list->model"