/** Returns the field to column mapping for the described class.
* For polymorphic persistency a single peanut can be mapped to several tables.
* This funtion returns a single fieldmap for all tables.
* When loading several tables may be JOINed by the database. Eventually
* missing data is loaded using an extra query. @see _getDescribedClassInstanceForData
*
* Because a fields persistence can be PNT_READ_ONLY, the map for
* loading the object is not necessarily the same as the map for saving.
* This method returns the fieldmap for loading, this includes fields whose
* propertyDescriptors' persistent === PNT_READ_ONLY
*
* ! There may still be methods that are not supporting fieldmapping
* ! Returns reference to cached Array, allways reset before using forEach or while each
* @return columnNameMapping Associative Array with field names as the keys and (unprefixed) column names as the values
*/
function () {
if ($this->fieldMap !== null)
return $this->fieldMap;
$this->fieldMap = array();
$props = $this->();
if (empty($props))
return $this->fieldMap;
reset($props);
foreach ($props as $name => $prop) {
$this->fieldMap[$prop->()] = $prop->();
}
return $this->fieldMap;
}
|