Skip to content

Record::$translate

James Cobban edited this page Jan 10, 2022 · 5 revisions

static Record::$translate

Up: class Record

This protected static attribute contains an associative array which is defined in each derived class to contain a translation from field name synonyms to actual field names. In the base class Record it is an empty array. It is used by static method Record::getRealFieldName to translate supplied field names into real field names. If the derived class implements any field names beyond the set of database record fields defined in static Record::$initRow they must be defined in this table. If an additional field name does not correspond to a database record field then it should be defined as translating to itself. For example class Citation provides through access to all of the fields in the associated instance of class Source that are not overridden by fields in class Citation. These fields are defined in Citation::$translate as mapping to the field names in class Source.

The following is an example from the class Name.

    protected static    $translate  = array(
                        'id'                    => 'idnx',
                        'given'                 => 'givenname',
                        '`order`'               => 'type',
                        'order'                 => 'type',
                        'gender'                => 'gender',
                        'suffix'                => 'title',
                        'createdby'             => 'marriednamecreatedby',
                        'marriednamemaridid'    => 'idmr',
                        'namenote'              => 'akanote',
                        'notes'                 => 'akanote'
                        );

If you wish to reuse the Family Tree functionality with a database which uses different field names that this table should define the mapping between the field names used by this application to the field names defined in your database.

Next: static Record::$defaultOrder

Clone this wiki locally