本文整理汇总了PHP中CRM_Contact_BAO_Query::getPrimaryCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Query::getPrimaryCondition方法的具体用法?PHP CRM_Contact_BAO_Query::getPrimaryCondition怎么用?PHP CRM_Contact_BAO_Query::getPrimaryCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Query
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Query::getPrimaryCondition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addHierarchicalElements
/**
* If the return Properties are set in a hierarchy, traverse the hierarchy to get
* the return values
*
* @return void
* @access public
*/
function addHierarchicalElements()
{
if (!CRM_Utils_Array::value('location', $this->_returnProperties)) {
return;
}
if (!is_array($this->_returnProperties['location'])) {
return;
}
$locationTypes = CRM_Core_PseudoConstant::locationType();
$processed = array();
$index = 0;
foreach ($this->_returnProperties['location'] as $name => $elements) {
$index++;
$lName = "`{$name}-location`";
$lCond = CRM_Contact_BAO_Query::getPrimaryCondition($name);
if ($lCond) {
$lCond = "{$lName}." . $lCond;
} else {
$locationTypeId = array_search($name, $locationTypes);
if ($locationTypeId === false) {
continue;
}
$lCond = "{$lName}.location_type_id = {$locationTypeId}";
}
$tName = "{$name}-location";
$this->_select["{$tName}_id"] = "`{$tName}`.id as `{$tName}_id`";
$this->_element["{$tName}_id"] = 1;
$this->_tables['civicrm_location_' . $index] = "\nLEFT JOIN civicrm_location {$lName} ON ({$lName}.entity_table = 'civicrm_contact' AND {$lName}.entity_id = civicrm_contact.id AND {$lCond} )";
$tName = "{$name}-location_type";
$ltName = "`{$name}-location_type`";
$this->_select["{$tName}_id"] = "`{$tName}`.id as `{$tName}_id`";
$this->_select["{$tName}"] = "`{$tName}`.name as `{$tName}`";
$this->_element["{$tName}_id"] = 1;
$this->_element["{$tName}"] = 1;
$this->_tables['civicrm_location_type_' . $index] = "\nLEFT JOIN civicrm_location_type {$ltName} ON ({$lName}.location_type_id = {$ltName}.id )";
$aName = "`{$name}-address`";
$tName = "{$name}-address";
$this->_select["{$tName}_id"] = "`{$tName}`.id as `{$tName}_id`";
$this->_element["{$tName}_id"] = 1;
$this->_tables['civicrm_address_' . $index] = "\nLEFT JOIN civicrm_address {$aName} ON ({$aName}.location_id = {$lName}.id)";
$processed[$lName] = $processed[$aName] = 1;
foreach ($elements as $elementFullName => $dontCare) {
$index++;
$cond = "is_primary = 1";
$elementName = $elementFullName;
$elementType = '';
if (strpos($elementName, '-')) {
// this is either phone, email or IM
list($elementName, $elementType) = explode('-', $elementName);
$cond = CRM_Contact_BAO_Query::getPrimaryCondition($elementType);
if (!$cond) {
$cond = "phone_type = '{$elementType}'";
}
$elementType = '-' . $elementType;
}
$field = CRM_Utils_Array::value($elementName, $this->_fields);
// hack for profile, add location id
if (!$field) {
if (!is_numeric($elementType)) {
//fix for CRM-882( to handle phone types )
$field =& CRM_Utils_Array::value($elementName . "-{$locationTypeId}{$elementType}", $this->_fields);
} else {
$field =& CRM_Utils_Array::value($elementName . "-{$locationTypeId}", $this->_fields);
}
}
if ($field && isset($field['where'])) {
list($tableName, $fieldName) = explode('.', $field['where'], 2);
$tName = $name . '-' . substr($tableName, 8) . $elementType;
$fieldName = $fieldName;
if (isset($tableName)) {
$this->_select["{$tName}_id"] = "`{$tName}`.id as `{$tName}_id`";
$this->_element["{$tName}_id"] = 1;
if (substr($tName, -15) == '-state_province') {
$this->_select["{$name}-{$elementFullName}"] = "`{$tName}`.abbreviation as `{$name}-{$elementFullName}`";
} else {
$this->_select["{$name}-{$elementFullName}"] = "`{$tName}`.{$fieldName} as `{$name}-{$elementFullName}`";
}
$this->_element["{$name}-{$elementFullName}"] = 1;
if (!CRM_Utils_Array::value("`{$tName}`", $processed)) {
$processed["`{$tName}`"] = 1;
switch ($tableName) {
case 'civicrm_phone':
case 'civicrm_email':
case 'civicrm_im':
$this->_tables[$tableName . '_' . $index] = "\nLEFT JOIN {$tableName} `{$tName}` ON {$lName}.id = `{$tName}`.location_id AND `{$tName}`.{$cond}";
break;
case 'civicrm_state_province':
$this->_tables[$tableName . '_' . $index] = "\nLEFT JOIN {$tableName} `{$tName}` ON `{$tName}`.id = {$aName}.state_province_id";
break;
case 'civicrm_country':
$this->_tables[$tableName . '_' . $index] = "\nLEFT JOIN {$tableName} `{$tName}` ON `{$tName}`.id = {$aName}.country_id";
break;
}
//.........这里部分代码省略.........