|Subscribe to DataMgr|
|Visit this group|
One of the most powerful features in DataMgr is the use of Relation Fields. Relation Fields act just like fields in the database table, but aren't actually stored as fields in the database. Instead, Relation Fields use data from related to return (and save) their values.
Relation Fields will be included in the recordset returned from getRecords() and can be specified in the fieldlist attribute or used for filtering in that method as well.
With the exception of aggregates and custom relation fields, the values underlying a relation field can be saved just as you would save a normal field as well.
The remainder of this section will discuss different types of Relation Fields. Except XML, no code examples will be given as these fields will act just like normal fields from the perspective of your use of DataMgr.
Note that Relation Fields can only point to physical fields in the database, not to other Relation Fields.
Relation Fields can be of the following types:
All relation fields (except custom) also have an optional onDelete attribute that covers how DataMgr should respond if the related record has data for the record being deleted.
For any Relation Field that has a join-field attribute, but no join-table attribute, the join-field represents the field name in both tables (and the must match). If the field names do not match, you can use the join-field-local (for the field name in the current table) and join-field-remote (for the field name in the related table) in place of the join-field attribute to make that distinction.
Note: You can create a Relation Field using loadXml() (as the examples below illustrate) or using the setColumn() method. If you use the setColumn() method, include a "Relation" argument, which will be a structure with keys matching the attributes of the "relation" element (not that keys with dashes "-" will have to be created with array format (eg relation["join-field"]).