ZMObject
└─ZMDbTableMapper
public class ZMDbTableMapper
extends ZMObject
| Field Summary | |
|---|---|
| final str | Key used to cache table mappings. |
| static mixed | Mapping of native data types to API types. |
| Fields inherited from org.zenmagick.core.ZMObject | |
|---|---|
| properties_ | |
| Constructor Summary | |
|---|---|
ZMDbTableMapper(string configFolder) Create a new instance. |
|
| Method Summary | |
|---|---|
| protected array | addCustomFields(array mapping, string table) Add a field list of custom fields for the given table. |
| array | buildTableMapping(string table, ZMDatabase database, boolean print) Generate a database mapping for the given table. |
| array | ensureMapping(mixed mapping, ZMDatabase database) Handle mixed mapping values. |
| array | getCustomFieldInfo(string table) Get field info map about custom fields for the given table. |
| array | getMapping(mixed tables, ZMDatabase database) Get a table map. |
| array | Get a list of all available tables. |
| static void | instance() Get instance. |
| boolean | isCached() Check if cached mappings are used. |
| protected void | Load mappings from file. |
| void | Refresh cache if empty. |
| protected array | parseTable(array mapping) Parse mapping for a single table. |
| void | setMappingForTable(string table, mixed mapping, array The) Set the mapping for the given table. |
| void | updateCache(ZMDatabase database) Create/update cache. |
| Methods inherited from org.zenmagick.core.ZMObject | |
|---|---|
| attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton | |
public final str CACHE_KEY = "ZMDbTableMapper::mappings"
Key used to cache table mappings.
public static mixed $NATIVE_TO_API_TYPEMAP = array(...)
Mapping of native data types to API types.
public ZMDbTableMapper(string configFolder)
Create a new instance.
protected array addCustomFields(array mapping, string table)
Add a field list of custom fields for the given table.
public array buildTableMapping(string table, ZMDatabase database, boolean print)
Generate a database mapping for the given table.
false.public array ensureMapping(mixed mapping, ZMDatabase database)
Handle mixed mapping values.
If enabled (via setting 'isEnableDBAutoMapping'), mappings for unknown tables will be build on demand.
null to use the default.null.public array getCustomFieldInfo(string table)
Get field info map about custom fields for the given table.
The returned array is a map with the property as key and an info map as value.
public array getMapping(mixed tables, ZMDatabase database)
Get a table map.
null.public array getTableNames()
Get a list of all available tables.
public static void instance()
Get instance.
public boolean isCached()
Check if cached mappings are used.
true if mappings have been loaded from cache.protected void loadMappingFile()
Load mappings from file.
public void onZMInitDone()
Refresh cache if empty.
protected array parseTable(array mapping)
Parse mapping for a single table.
public void setMappingForTable(string table, mixed mapping, array The)
Set the mapping for the given table.
NOTE: This will silently override mappings for existing tables.
public void updateCache(ZMDatabase database)
Create/update cache.
Database table mapping *service*.
This class will read and parse file(s) containing model-database mappings. The code can map a single model class to a database table. Mappings are configured using nested arrays and wll be parsed into something
ZMDatabaseimplementations can understand and use.A simple mapping could look like this:
Each mapping has the table name as key (without any prefix) and an array of field mappings as value.
Each entry maps a single model property to a table column. The key is the model property name (starting lowercase). Available *attributes* are:/p>
ZM_DATE_FORMAT)ZM_DATETIME_FORMAT)truethis field is part of a table key.