From 66abbb6d832a983e527cbfde8662c8c8b43c991a Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Thu, 2 May 2013 16:35:01 -0700 Subject: [PATCH] Added method fieldKeys() to DAOs. CRM-12464 ---------------------------------------- * CRM-12464: Search improvements in 4.4 http://issues.civicrm.org/jira/browse/CRM-12464 --- xml/templates/dao.tpl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/xml/templates/dao.tpl b/xml/templates/dao.tpl index 1468302a7d..b5211939b7 100644 --- a/xml/templates/dao.tpl +++ b/xml/templates/dao.tpl @@ -64,6 +64,14 @@ class {$table.className} extends CRM_Core_DAO {ldelim} */ static $_fields = null; + /** + * static instance to hold the keys used in $_fields for each field. + * + * @var array + * @static + */ + static $_fieldKeys = null; + /** * static instance to hold the FK relationships * @@ -227,6 +235,30 @@ class {$table.className} extends CRM_Core_DAO {ldelim} return self::$_fields; {rdelim} + /** + * Returns an array containing, for each field, the arary key used for that + * field in self::$_fields. + * + * @access public + * @return array + */ + static function &fieldKeys( ) {ldelim} + if ( ! ( self::$_fieldKeys ) ) {ldelim} + self::$_fieldKeys = array ( +{foreach from=$table.fields item=field} + '{$field.name}' => +{if $field.uniqueName} + '{$field.uniqueName}' +{else} + '{$field.name}' +{/if}, + +{/foreach} {* table.fields *} + ); + {rdelim} + return self::$_fieldKeys; + {rdelim} + /** * returns the names of this table * -- 2.25.1