本文整理汇总了PHP中CRM_Contact_BAO_Contact::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::fetch方法的具体用法?PHP CRM_Contact_BAO_Contact::fetch怎么用?PHP CRM_Contact_BAO_Contact::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::fetch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateDisplayNames
/**
* Regenerates display_name for contacts with given prefixes/suffixes.
*
* @param array $ids
* The array with the prefix/suffix id governing which contacts to regenerate.
* @param int $action
* The action describing whether prefix/suffix was UPDATED or DELETED.
*/
public static function updateDisplayNames(&$ids, $action)
{
// get the proper field name (prefix_id or suffix_id) and its value
$fieldName = '';
foreach ($ids as $key => $value) {
switch ($key) {
case 'individualPrefix':
$fieldName = 'prefix_id';
$fieldValue = $value;
break 2;
case 'individualSuffix':
$fieldName = 'suffix_id';
$fieldValue = $value;
break 2;
}
}
if ($fieldName == '') {
return;
}
// query for the affected individuals
$fieldValue = CRM_Utils_Type::escape($fieldValue, 'Integer');
$contact = new CRM_Contact_BAO_Contact();
$contact->{$fieldName} = $fieldValue;
$contact->find();
// iterate through the affected individuals and rebuild their display_names
while ($contact->fetch()) {
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contact->contact_id;
if ($action == CRM_Core_Action::DELETE) {
$contact->{$fieldName} = 'NULL';
$contact->save();
}
$contact->display_name = $contact->displayName();
$contact->save();
}
}