Record::getRealFieldName - jcobban/Genealogy GitHub Wiki
Record::getRealFieldName($fldname)
Up: class Record
This static method performs a standard algorithm for the class to obtain the internal name of a field from a suggested field name. This method uses late static binding so that it will use the internal definition tables for whichever class it is invoked for. This eliminates the need for a requestor to have access to the internal tables $initRow and $translate and ensures that the translation is performed in a consistent way in all scripts.
parameter | description |
---|---|
$fldname | A suggested field name, case insensitive, to be translated to the field name to be used in an SQL request. |
This method returns a string containing a field name in lower case so it matches the member of the internal associative array of field values for an instance of Record. If the requested field name is not defined for the table this method returns null.
This method can be overridden in a derived class to return an SQL expression that extracts a value from the row of the table which is translated to a simulated field name by an "AS" clause so it is valid to insert it into the field name list portion of a SELECT statement. Examples:
$fldname = Name::getRealFieldName('idmr');
Returns 'marriednamemaridid'.
$fldname = Domain::getRealFieldName('cc');
The derived method Domain::getRealFieldName returns "LEFT(`Domain`,2) AS CountryCode".