本文整理汇总了PHP中CRM_Core_DAO_CustomField::free方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_CustomField::free方法的具体用法?PHP CRM_Core_DAO_CustomField::free怎么用?PHP CRM_Core_DAO_CustomField::free使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO_CustomField
的用法示例。
在下文中一共展示了CRM_Core_DAO_CustomField::free方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: VARCHAR
function upgrade_3_3_alpha1($rev)
{
$config = CRM_Core_Config::singleton();
if ($config->userSystem->is_drupal) {
// CRM-6426 - make civicrm profiles permissioned on drupal my account
$config->userSystem->updateCategories();
}
// CRM-6846
// insert name column for custom field table.
// make sure name for custom field, group and
// profile should be unique and properly munged.
$colQuery = 'ALTER TABLE `civicrm_custom_field` ADD `name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER `custom_group_id` ';
CRM_Core_DAO::executeQuery($colQuery, CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
$customFldCntQuery = 'select count(*) from civicrm_custom_field where name like %1 and id != %2';
$customField = new CRM_Core_DAO_CustomField();
$customField->selectAdd();
$customField->selectAdd('id, label');
$customField->find();
while ($customField->fetch()) {
$name = CRM_Utils_String::munge($customField->label, '_', 64);
$fldCnt = CRM_Core_DAO::singleValueQuery($customFldCntQuery, array(1 => array($name, 'String'), 2 => array($customField->id, 'Integer')), TRUE, FALSE);
if ($fldCnt) {
$name = CRM_Utils_String::munge("{$name}_" . rand(), '_', 64);
}
$customFieldQuery = "\nUpdate `civicrm_custom_field`\nSET `name` = %1\nWHERE id = %2\n";
$customFieldParams = array(1 => array($name, 'String'), 2 => array($customField->id, 'Integer'));
CRM_Core_DAO::executeQuery($customFieldQuery, $customFieldParams, TRUE, NULL, FALSE, FALSE);
}
$customField->free();
$customGrpCntQuery = 'select count(*) from civicrm_custom_group where name like %1 and id != %2';
$customGroup = new CRM_Core_DAO_CustomGroup();
$customGroup->selectAdd();
$customGroup->selectAdd('id, title');
$customGroup->find();
while ($customGroup->fetch()) {
$name = CRM_Utils_String::munge($customGroup->title, '_', 64);
$grpCnt = CRM_Core_DAO::singleValueQuery($customGrpCntQuery, array(1 => array($name, 'String'), 2 => array($customGroup->id, 'Integer')));
if ($grpCnt) {
$name = CRM_Utils_String::munge("{$name}_" . rand(), '_', 64);
}
CRM_Core_DAO::setFieldValue('CRM_Core_DAO_CustomGroup', $customGroup->id, 'name', $name);
}
$customGroup->free();
$ufGrpCntQuery = 'select count(*) from civicrm_uf_group where name like %1 and id != %2';
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->selectAdd();
$ufGroup->selectAdd('id, title');
$ufGroup->find();
while ($ufGroup->fetch()) {
$name = CRM_Utils_String::munge($ufGroup->title, '_', 64);
$ufGrpCnt = CRM_Core_DAO::singleValueQuery($ufGrpCntQuery, array(1 => array($name, 'String'), 2 => array($ufGroup->id, 'Integer')));
if ($ufGrpCnt) {
$name = CRM_Utils_String::munge("{$name}_" . rand(), '_', 64);
}
CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $ufGroup->id, 'name', $name);
}
$ufGroup->free();
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
// now modify the config so that the directories are stored in option group/value
// CRM-6914
// require_once 'CRM/Core/BAO/ConfigSetting.php';
// $params = array( );
// CRM_Core_BAO_ConfigSetting::add( $parambs );
}
示例2: get
/**
* Low-level option getter, rarely accessed directly.
* NOTE: Rather than calling this function directly use CRM_*_BAO_*::buildOptions()
*
* @param String $daoName
* @param String $fieldName
* @param Array $params
* - name string name of the option group
* - flip boolean results are return in id => label format if false
* if true, the results are reversed
* - grouping boolean if true, return the value in 'grouping' column (currently unsupported for tables other than option_value)
* - localize boolean if true, localize the results before returning
* - condition string|array add condition(s) to the sql query - will be concatenated using 'AND'
* - keyColumn string the column to use for 'id'
* - labelColumn string the column to use for 'label'
* - orderColumn string the column to use for sorting, defaults to 'weight' column if one exists, else defaults to labelColumn
* - onlyActive boolean return only the action option values
* - fresh boolean ignore cache entries and go back to DB
* @param String $context: Context string
*
* @return Array on success, FALSE on error.
*
* @static
*/
public static function get($daoName, $fieldName, $params = array(), $context = NULL)
{
CRM_Core_DAO::buildOptionsContext($context);
$flip = !empty($params['flip']);
// Merge params with defaults
$params += array('grouping' => FALSE, 'localize' => FALSE, 'onlyActive' => $context == 'validate' || $context == 'get' ? FALSE : TRUE, 'fresh' => FALSE);
// Custom fields are not in the schema
if (strpos($fieldName, 'custom_') === 0 && is_numeric($fieldName[7])) {
$customField = new CRM_Core_DAO_CustomField();
$customField->id = (int) substr($fieldName, 7);
$customField->find(TRUE);
$options = FALSE;
if (!empty($customField->option_group_id)) {
$options = CRM_Core_OptionGroup::valuesByID($customField->option_group_id, $flip, $params['grouping'], $params['localize'], CRM_Utils_Array::value('labelColumn', $params, 'label'), $params['onlyActive'], $params['fresh']);
} else {
if ($customField->data_type === 'StateProvince') {
$options = self::stateProvince();
} elseif ($customField->data_type === 'Country') {
$options = $context == 'validate' ? self::countryIsoCode() : self::country();
} elseif ($customField->data_type === 'Boolean') {
$options = $context == 'validate' ? array(0, 1) : array(1 => ts('Yes'), 0 => ts('No'));
}
$options = $options && $flip ? array_flip($options) : $options;
}
if ($options !== FALSE) {
CRM_Utils_Hook::customFieldOptions($customField->id, $options, FALSE);
}
$customField->free();
return $options;
}
// Core field: load schema
$dao = new $daoName();
$fields = $dao->fields();
$fieldKeys = $dao->fieldKeys();
$dao->free();
// Support "unique names" as well as sql names
$fieldKey = $fieldName;
if (empty($fields[$fieldKey])) {
$fieldKey = CRM_Utils_Array::value($fieldName, $fieldKeys);
}
// If neither worked then this field doesn't exist. Return false.
if (empty($fields[$fieldKey])) {
return FALSE;
}
$fieldSpec = $fields[$fieldKey];
// If the field is an enum, explode the enum definition and return the array.
if (isset($fieldSpec['enumValues'])) {
// use of a space after the comma is inconsistent in xml
$enumStr = str_replace(', ', ',', $fieldSpec['enumValues']);
$output = explode(',', $enumStr);
return array_combine($output, $output);
} elseif (!empty($fieldSpec['pseudoconstant'])) {
$pseudoconstant = $fieldSpec['pseudoconstant'];
// Merge params with schema defaults
$params += array('condition' => CRM_Utils_Array::value('condition', $pseudoconstant, array()), 'keyColumn' => CRM_Utils_Array::value('keyColumn', $pseudoconstant), 'labelColumn' => CRM_Utils_Array::value('labelColumn', $pseudoconstant));
// Fetch option group from option_value table
if (!empty($pseudoconstant['optionGroupName'])) {
if ($context == 'validate') {
$params['labelColumn'] = 'name';
}
// Call our generic fn for retrieving from the option_value table
return CRM_Core_OptionGroup::values($pseudoconstant['optionGroupName'], $flip, $params['grouping'], $params['localize'], $params['condition'] ? ' AND ' . implode(' AND ', (array) $params['condition']) : NULL, $params['labelColumn'] ? $params['labelColumn'] : 'label', $params['onlyActive'], $params['fresh'], $params['keyColumn'] ? $params['keyColumn'] : 'value');
}
// Fetch options from other tables
if (!empty($pseudoconstant['table'])) {
// Normalize params so the serialized cache string will be consistent.
CRM_Utils_Array::remove($params, 'flip', 'fresh');
ksort($params);
$cacheKey = $daoName . $fieldName . serialize($params);
// Retrieve cached options
if (isset(self::$cache[$cacheKey]) && empty($params['fresh'])) {
$output = self::$cache[$cacheKey];
} else {
$daoName = CRM_Core_DAO_AllCoreTables::getClassForTable($pseudoconstant['table']);
if (!class_exists($daoName)) {
return FALSE;
//.........这里部分代码省略.........