* @var array
*/
static $_fields = null;
- /**
- * static instance to hold the keys used in $_fields for each field.
- *
- * @var array
- */
- static $_fieldKeys = null;
/**
* static instance to hold the FK relationships
*
return self::$_fields;
}
/**
- * Returns an array containing, for each field, the arary key used for that
- * field in self::$_fields.
+ * Return a mapping from field-name to the corresponding key (as used in fields()).
*
* @return array
+ * Array(string $name => string $uniqueName).
*/
static function &fieldKeys() {
- if (!(self::$_fieldKeys)) {
- self::$_fieldKeys = array(
- 'id' => 'id',
- 'event_queue_id' => 'event_queue_id',
- 'time_stamp' => 'time_stamp',
- );
+ if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
+ Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
}
- return self::$_fieldKeys;
+ return Civi::$statics[__CLASS__]['fieldKeys'];
}
/**
* Returns the names of this table