本文整理汇总了PHP中CRM_Core_OptionValue::select方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_OptionValue::select方法的具体用法?PHP CRM_Core_OptionValue::select怎么用?PHP CRM_Core_OptionValue::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_OptionValue
的用法示例。
在下文中一共展示了CRM_Core_OptionValue::select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectClause
/**
* Given a list of conditions in params and a list of desired
* return Properties generate the required select and from
* clauses. Note that since the where clause introduces new
* tables, the initial attempt also retrieves all variables used
* in the params list
*
* @return void
* @access public
*/
function selectClause()
{
$properties = array();
$this->addSpecialFields();
// CRM_Core_Error::debug( 'f', $this->_fields );
// CRM_Core_Error::debug( 'p', $this->_params );
// CRM_Core_Error::debug( 'p', $this->_paramLookup );
foreach ($this->_fields as $name => $field) {
// skip component fields
// there are done by the alter query below
// and need not be done on every field
if (substr($name, 0, 12) == 'participant_' || substr($name, 0, 7) == 'pledge_' || substr($name, 0, 5) == 'case_') {
continue;
}
// redirect to activity select clause
if (substr($name, 0, 9) == 'activity_') {
CRM_Activity_BAO_Query::select($this);
continue;
}
// if this is a hierarchical name, we ignore it
$names = explode('-', $name);
if (count($names > 1) && isset($names[1]) && is_numeric($names[1])) {
continue;
}
$cfID = CRM_Core_BAO_CustomField::getKeyID($name);
if (CRM_Utils_Array::value($name, $this->_paramLookup) || CRM_Utils_Array::value($name, $this->_returnProperties)) {
if ($cfID) {
// add to cfIDs array if not present
if (!array_key_exists($cfID, $this->_cfIDs)) {
$this->_cfIDs[$cfID] = array();
}
} elseif (isset($field['where'])) {
list($tableName, $fieldName) = explode('.', $field['where'], 2);
if (isset($tableName)) {
if (substr($tableName, 0, 6) == 'quest_') {
$this->_select['ethnicity_id_1'] = 'ethnicity_id_1';
$this->_select['gpa_weighted_calc'] = 'gpa_weighted_calc';
$this->_select['SAT_composite'] = 'SAT_composite';
$this->_select['household_income_total'] = 'household_income_total';
}
if (CRM_Utils_Array::value($tableName, self::$_dependencies)) {
$this->_tables['civicrm_address'] = 1;
$this->_select['address_id'] = 'civicrm_address.id as address_id';
$this->_element['address_id'] = 1;
}
if ($tableName == 'gender' || $tableName == 'individual_prefix' || $tableName == 'individual_suffix' || $tableName == 'im_provider' || $tableName == 'email_greeting' || $tableName == 'postal_greeting' || $tableName == 'addressee') {
CRM_Core_OptionValue::select($this);
if (in_array($tableName, array('email_greeting', 'postal_greeting', 'addressee'))) {
//get display
$greetField = "{$name}_display";
$this->_select[$greetField] = "contact_a.{$greetField} as {$greetField}";
$this->_element[$greetField] = 1;
//get custom
$greetField = "{$name}_custom";
$this->_select[$greetField] = "contact_a.{$greetField} as {$greetField}";
$this->_element[$greetField] = 1;
}
} else {
$this->_tables[$tableName] = 1;
// also get the id of the tableName
$tName = substr($tableName, 8);
if ($tName != 'contact') {
$this->_select["{$tName}_id"] = "{$tableName}.id as {$tName}_id";
$this->_element["{$tName}_id"] = 1;
}
//special case for phone
if ($name == 'phone') {
$this->_select['phone_type_id'] = "civicrm_phone.phone_type_id as phone_type_id";
$this->_element['phone_type_id'] = 1;
}
// if IM then select provider_id also
// to get "IM Service Provider" in a file to be exported, CRM-3140
if ($name == 'im') {
$this->_select['provider_id'] = "civicrm_im.provider_id as provider_id";
$this->_element['provider_id'] = 1;
}
if ($name == 'state_province') {
$this->_select[$name] = "civicrm_state_province.abbreviation as `{$name}`, civicrm_state_province.name as state_province_name";
$this->_element['state_province_name'] = 1;
} elseif ($tName == 'contact') {
// special case, when current employer is set for Individual contact
if ($fieldName == 'organization_name') {
$this->_select[$name] = "IF ( contact_a.contact_type = 'Individual', NULL, contact_a.organization_name ) as organization_name";
} elseif ($fieldName != 'id') {
$this->_select[$name] = "contact_a.{$fieldName} as `{$name}`";
}
} else {
$this->_select[$name] = "{$field['where']} as `{$name}`";
}
$this->_element[$name] = 1;
//.........这里部分代码省略.........
示例2: selectClause
/**
* Given a list of conditions in params and a list of desired
* return Properties generate the required select and from
* clauses. Note that since the where clause introduces new
* tables, the initial attempt also retrieves all variables used
* in the params list
*/
public function selectClause()
{
$this->addSpecialFields();
foreach ($this->_fields as $name => $field) {
// skip component fields
// there are done by the alter query below
// and need not be done on every field
if (substr($name, 0, 12) == 'participant_' || substr($name, 0, 7) == 'pledge_' || substr($name, 0, 5) == 'case_' || substr($name, 0, 13) == 'contribution_' && (strpos($name, 'source') !== FALSE && strpos($name, 'recur') !== FALSE) || substr($name, 0, 8) == 'payment_') {
continue;
}
// redirect to activity select clause
if (substr($name, 0, 9) == 'activity_' || $name == 'parent_id') {
CRM_Activity_BAO_Query::select($this);
continue;
}
// if this is a hierarchical name, we ignore it
$names = explode('-', $name);
if (count($names) > 1 && isset($names[1]) && is_numeric($names[1])) {
continue;
}
// make an exception for special cases, to add the field in select clause
$makeException = FALSE;
//special handling for groups/tags
if (in_array($name, array('groups', 'tags', 'notes')) && isset($this->_returnProperties[substr($name, 0, -1)])) {
$makeException = TRUE;
}
// since note has 3 different options we need special handling
// note / note_subject / note_body
if ($name == 'notes') {
foreach (array('note', 'note_subject', 'note_body') as $noteField) {
if (isset($this->_returnProperties[$noteField])) {
$makeException = TRUE;
break;
}
}
}
if (in_array($name, array('prefix_id', 'suffix_id', 'gender_id', 'communication_style_id'))) {
if (CRM_Utils_Array::value($field['pseudoconstant']['optionGroupName'], $this->_returnProperties)) {
$makeException = TRUE;
}
}
$cfID = CRM_Core_BAO_CustomField::getKeyID($name);
if (!empty($this->_paramLookup[$name]) || !empty($this->_returnProperties[$name]) || $makeException) {
if ($cfID) {
// add to cfIDs array if not present
if (!array_key_exists($cfID, $this->_cfIDs)) {
$this->_cfIDs[$cfID] = array();
}
} elseif (isset($field['where'])) {
list($tableName, $fieldName) = explode('.', $field['where'], 2);
if (isset($tableName)) {
if (CRM_Utils_Array::value($tableName, self::$_dependencies)) {
$this->_tables['civicrm_address'] = 1;
$this->_select['address_id'] = 'civicrm_address.id as address_id';
$this->_element['address_id'] = 1;
}
if ($tableName == 'im_provider' || $tableName == 'email_greeting' || $tableName == 'postal_greeting' || $tableName == 'addressee') {
if ($tableName == 'im_provider') {
CRM_Core_OptionValue::select($this);
}
if (in_array($tableName, array('email_greeting', 'postal_greeting', 'addressee'))) {
$this->_element["{$name}_id"] = 1;
$this->_select["{$name}_id"] = "contact_a.{$name}_id as {$name}_id";
$this->_pseudoConstantsSelect[$name] = array('pseudoField' => $tableName, 'idCol' => "{$name}_id");
$this->_pseudoConstantsSelect[$name]['select'] = "{$name}.{$fieldName} as {$name}";
$this->_pseudoConstantsSelect[$name]['element'] = $name;
if ($tableName == 'email_greeting') {
$this->_pseudoConstantsSelect[$name]['join'] = " LEFT JOIN civicrm_option_group option_group_email_greeting ON (option_group_email_greeting.name = 'email_greeting')";
$this->_pseudoConstantsSelect[$name]['join'] .= " LEFT JOIN civicrm_option_value email_greeting ON (contact_a.email_greeting_id = email_greeting.value AND option_group_email_greeting.id = email_greeting.option_group_id ) ";
} elseif ($tableName == 'postal_greeting') {
$this->_pseudoConstantsSelect[$name]['join'] = " LEFT JOIN civicrm_option_group option_group_postal_greeting ON (option_group_postal_greeting.name = 'postal_greeting')";
$this->_pseudoConstantsSelect[$name]['join'] .= " LEFT JOIN civicrm_option_value postal_greeting ON (contact_a.postal_greeting_id = postal_greeting.value AND option_group_postal_greeting.id = postal_greeting.option_group_id ) ";
} elseif ($tableName == 'addressee') {
$this->_pseudoConstantsSelect[$name]['join'] = " LEFT JOIN civicrm_option_group option_group_addressee ON (option_group_addressee.name = 'addressee')";
$this->_pseudoConstantsSelect[$name]['join'] .= " LEFT JOIN civicrm_option_value addressee ON (contact_a.addressee_id = addressee.value AND option_group_addressee.id = addressee.option_group_id ) ";
}
$this->_pseudoConstantsSelect[$name]['table'] = $tableName;
//get display
$greetField = "{$name}_display";
$this->_select[$greetField] = "contact_a.{$greetField} as {$greetField}";
$this->_element[$greetField] = 1;
//get custom
$greetField = "{$name}_custom";
$this->_select[$greetField] = "contact_a.{$greetField} as {$greetField}";
$this->_element[$greetField] = 1;
}
} else {
if (!in_array($tableName, array('civicrm_state_province', 'civicrm_country', 'civicrm_county'))) {
$this->_tables[$tableName] = 1;
}
// also get the id of the tableName
$tName = substr($tableName, 8);
if (in_array($tName, array('country', 'state_province', 'county'))) {
//.........这里部分代码省略.........