Regen DAOs with new fieldKeys()
[civicrm-core.git] / CRM / Mailing / Event / DAO / Opened.php
index 8ea1b5c93dc11e48fe2734c4ec21683b23bb59d7..6a07125eaea7b3b1dff4be257b99726728da9ac3 100644 (file)
@@ -47,12 +47,6 @@ class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO {
    * @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
    *
@@ -139,20 +133,16 @@ class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO {
     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