/** Initialize an existing object from an associative array retrieved from the datbase.
*
* @param $assocArray Associative Array with the columnNames as keys and the values as values
* @param $fieldMap Associative Array with the fieldNames as keys and the corresponding columnNames as values
* @returns Associative Array mapping the fields that where not in $assocArray
*/
function &($assocArray, &$fieldMap) {
$missingFieldsMap = array();
reset($fieldMap);
foreach ($fieldMap as $field => $column)
if ( isSet( $assocArray[$column] ) ) {
$this->$field = $assocArray[$column];
} else {
$missingFieldsMap[$field] = $column;
}
return $missingFieldsMap;
}
|