本文整理汇总了PHP中CRM_Core_Component::tableNames方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Component::tableNames方法的具体用法?PHP CRM_Core_Component::tableNames怎么用?PHP CRM_Core_Component::tableNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Component
的用法示例。
在下文中一共展示了CRM_Core_Component::tableNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromClause
/**
* Create the from clause.
*
* @param array $tables
* Tables that need to be included in this from clause.
* if null, return mimimal from clause (i.e. civicrm_contact)
* @param array $inner
* Tables that should be inner-joined.
* @param array $right
* Tables that should be right-joined.
*
* @param bool $primaryLocation
* @param int $mode
*
* @return string
* the from clause
*/
public static function fromClause(&$tables, $inner = NULL, $right = NULL, $primaryLocation = TRUE, $mode = 1)
{
$from = ' FROM civicrm_contact contact_a';
if (empty($tables)) {
return $from;
}
if (!empty($tables['civicrm_worldregion'])) {
$tables = array_merge(array('civicrm_country' => 1), $tables);
}
if ((!empty($tables['civicrm_state_province']) || !empty($tables['civicrm_country']) || CRM_Utils_Array::value('civicrm_county', $tables)) && empty($tables['civicrm_address'])) {
$tables = array_merge(array('civicrm_address' => 1), $tables);
}
// add group_contact and group_contact_cache table if group table is present
if (!empty($tables['civicrm_group'])) {
if (empty($tables['civicrm_group_contact'])) {
$tables['civicrm_group_contact'] = " LEFT JOIN civicrm_group_contact ON civicrm_group_contact.contact_id = contact_a.id AND civicrm_group_contact.status = 'Added' ";
}
if (empty($tables['civicrm_group_contact_cache'])) {
$tables['civicrm_group_contact_cache'] = " LEFT JOIN civicrm_group_contact_cache ON civicrm_group_contact_cache.contact_id = contact_a.id ";
}
}
// add group_contact and group table is subscription history is present
if (!empty($tables['civicrm_subscription_history']) && empty($tables['civicrm_group'])) {
$tables = array_merge(array('civicrm_group' => 1, 'civicrm_group_contact' => 1), $tables);
}
// to handle table dependencies of components
CRM_Core_Component::tableNames($tables);
// to handle table dependencies of hook injected tables
CRM_Contact_BAO_Query_Hook::singleton()->setTableDependency($tables);
//format the table list according to the weight
$info = CRM_Core_TableHierarchy::info();
foreach ($tables as $key => $value) {
$k = 99;
if (strpos($key, '-') !== FALSE) {
$keyArray = explode('-', $key);
$k = CRM_Utils_Array::value('civicrm_' . $keyArray[1], $info, 99);
} elseif (strpos($key, '_') !== FALSE) {
$keyArray = explode('_', $key);
if (is_numeric(array_pop($keyArray))) {
$k = CRM_Utils_Array::value(implode('_', $keyArray), $info, 99);
} else {
$k = CRM_Utils_Array::value($key, $info, 99);
}
} else {
$k = CRM_Utils_Array::value($key, $info, 99);
}
$tempTable[$k . ".{$key}"] = $key;
}
ksort($tempTable);
$newTables = array();
foreach ($tempTable as $key) {
$newTables[$key] = $tables[$key];
}
$tables = $newTables;
foreach ($tables as $name => $value) {
if (!$value) {
continue;
}
if (!empty($inner[$name])) {
$side = 'INNER';
} elseif (!empty($right[$name])) {
$side = 'RIGHT';
} else {
$side = 'LEFT';
}
if ($value != 1) {
// if there is already a join statement in value, use value itself
if (strpos($value, 'JOIN')) {
$from .= " {$value} ";
} else {
$from .= " {$side} JOIN {$name} ON ( {$value} ) ";
}
continue;
}
switch ($name) {
case 'civicrm_address':
if ($primaryLocation) {
$from .= " {$side} JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 )";
} else {
//CRM-14263 further handling of address joins further down...
$from .= " {$side} JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id ) ";
}
continue;
//.........这里部分代码省略.........
示例2: fromClause
/**
* create the from clause
*
* @param array $tables tables that need to be included in this from clause
* if null, return mimimal from clause (i.e. civicrm_contact)
* @param array $inner tables that should be inner-joined
* @param array $right tables that should be right-joined
*
* @return string the from clause
* @access public
* @static
*/
static function fromClause(&$tables, $inner = NULL, $right = NULL, $primaryLocation = TRUE, $mode = 1)
{
$from = ' FROM civicrm_contact contact_a';
if (empty($tables)) {
return $from;
}
if (CRM_Utils_Array::value('civicrm_worldregion', $tables)) {
$tables = array_merge(array('civicrm_country' => 1), $tables);
}
if ((CRM_Utils_Array::value('civicrm_state_province', $tables) || CRM_Utils_Array::value('civicrm_country', $tables) || CRM_Utils_Array::value('civicrm_county', $tables)) && !CRM_Utils_Array::value('civicrm_address', $tables)) {
$tables = array_merge(array('civicrm_address' => 1), $tables);
}
// add group_contact table if group table is present
if (CRM_Utils_Array::value('civicrm_group', $tables) && !CRM_Utils_Array::value('civicrm_group_contact', $tables)) {
$tables['civicrm_group_contact'] = " LEFT JOIN civicrm_group_contact ON civicrm_group_contact.contact_id = contact_a.id AND civicrm_group_contact.status = 'Added'";
}
// add group_contact and group table is subscription history is present
if (CRM_Utils_Array::value('civicrm_subscription_history', $tables) && !CRM_Utils_Array::value('civicrm_group', $tables)) {
$tables = array_merge(array('civicrm_group' => 1, 'civicrm_group_contact' => 1), $tables);
}
// to handle table dependencies of components
CRM_Core_Component::tableNames($tables);
//format the table list according to the weight
$info = CRM_Core_TableHierarchy::info();
foreach ($tables as $key => $value) {
$k = 99;
if (strpos($key, '-') !== FALSE) {
$keyArray = explode('-', $key);
$k = CRM_Utils_Array::value('civicrm_' . $keyArray[1], $info, 99);
} elseif (strpos($key, '_') !== FALSE) {
$keyArray = explode('_', $key);
if (is_numeric(array_pop($keyArray))) {
$k = CRM_Utils_Array::value(implode('_', $keyArray), $info, 99);
} else {
$k = CRM_Utils_Array::value($key, $info, 99);
}
} else {
$k = CRM_Utils_Array::value($key, $info, 99);
}
$tempTable[$k . ".{$key}"] = $key;
}
ksort($tempTable);
$newTables = array();
foreach ($tempTable as $key) {
$newTables[$key] = $tables[$key];
}
$tables = $newTables;
foreach ($tables as $name => $value) {
if (!$value) {
continue;
}
if (CRM_Utils_Array::value($name, $inner)) {
$side = 'INNER';
} elseif (CRM_Utils_Array::value($name, $right)) {
$side = 'RIGHT';
} else {
$side = 'LEFT';
}
if ($value != 1) {
// if there is already a join statement in value, use value itself
if (strpos($value, 'JOIN')) {
$from .= " {$value} ";
} else {
$from .= " {$side} JOIN {$name} ON ( {$value} ) ";
}
continue;
}
switch ($name) {
case 'civicrm_address':
if ($primaryLocation) {
$from .= " {$side} JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 )";
} else {
$from .= " {$side} JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id ) ";
}
continue;
case 'civicrm_phone':
$from .= " {$side} JOIN civicrm_phone ON (contact_a.id = civicrm_phone.contact_id AND civicrm_phone.is_primary = 1) ";
continue;
case 'civicrm_email':
$from .= " {$side} JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1) ";
continue;
case 'civicrm_im':
$from .= " {$side} JOIN civicrm_im ON (contact_a.id = civicrm_im.contact_id AND civicrm_im.is_primary = 1) ";
continue;
case 'im_provider':
$from .= " {$side} JOIN civicrm_im ON (contact_a.id = civicrm_im.contact_id) ";
$from .= " {$side} JOIN civicrm_option_group option_group_imProvider ON option_group_imProvider.name = 'instant_messenger_service'";
$from .= " {$side} JOIN civicrm_option_value im_provider ON (civicrm_im.provider_id = im_provider.value AND option_group_imProvider.id = im_provider.option_group_id)";
//.........这里部分代码省略.........
示例3: fromClause
/**
* Create the from clause.
*
* @param array $tables
* Tables that need to be included in this from clause.
* if null, return mimimal from clause (i.e. civicrm_relationship)
* @param array $inner
* Tables that should be inner-joined.
* @param array $right
* Tables that should be right-joined.
*
* @return string
* the from clause
*/
public static function fromClause(&$tables, $inner = NULL, $right = NULL)
{
$from = ' FROM civicrm_relationship relationship';
if (empty($tables)) {
return $from;
}
// to handle table dependencies of components
CRM_Core_Component::tableNames($tables);
//format the table list according to the weight
$info = CRM_Core_TableHierarchy::info();
foreach ($tables as $key => $value) {
$k = 99;
if (strpos($key, '-') !== FALSE) {
$keyArray = explode('-', $key);
$k = CRM_Utils_Array::value('civicrm_' . $keyArray[1], $info, 99);
} elseif (strpos($key, '_') !== FALSE) {
$keyArray = explode('_', $key);
if (is_numeric(array_pop($keyArray))) {
$k = CRM_Utils_Array::value(implode('_', $keyArray), $info, 99);
} else {
$k = CRM_Utils_Array::value($key, $info, 99);
}
} else {
$k = CRM_Utils_Array::value($key, $info, 99);
}
$tempTable[$k . ".{$key}"] = $key;
}
ksort($tempTable);
$newTables = array();
foreach ($tempTable as $key) {
$newTables[$key] = $tables[$key];
}
$tables = $newTables;
foreach ($tables as $name => $value) {
if (!$value) {
continue;
}
if (!empty($inner[$name])) {
$side = 'INNER';
} elseif (!empty($right[$name])) {
$side = 'RIGHT';
} else {
$side = 'LEFT';
}
if ($value != 1) {
// if there is already a join statement in value, use value itself
if (strpos($value, 'JOIN')) {
$from .= " {$value} ";
} else {
$from .= " {$side} JOIN {$name} ON ( {$value} ) ";
}
continue;
}
switch ($name) {
case 'civicrm_relationship':
continue;
case 'civicrm_relationship_type':
$from .= " {$side} JOIN civicrm_relationship_type relationship_type ON relationship.relationship_type_id = relationship_type.id ";
continue;
case 'contact_a':
$from .= " {$side} JOIN civicrm_contact contact_a ON relationship.contact_id_a = contact_a.id ";
continue;
case 'contact_b':
$from .= " {$side} JOIN civicrm_contact contact_b ON relationship.contact_id_b = contact_b.id ";
continue;
case 'contact_a_email':
$from .= " {$side} JOIN civicrm_email contact_a_email ON (contact_a.id = contact_a_email.contact_id AND contact_a_email.is_primary = 1) ";
continue;
case 'contact_b_email':
$from .= " {$side} JOIN civicrm_email contact_b_email ON (contact_b.id = contact_b_email.contact_id AND contact_b_email.is_primary = 1) ";
continue;
case 'contact_a_phone':
$from .= " {$side} JOIN civicrm_phone contact_a_phone ON (contact_a.id = contact_a_phone.contact_id AND contact_a_phone.is_primary = 1) ";
continue;
case 'contact_b_phone':
$from .= " {$side} JOIN civicrm_phone contact_b_phone ON (contact_b.id = contact_b_phone.contact_id AND contact_b_phone.is_primary = 1) ";
continue;
case 'contact_a_address':
$from .= " {$side} JOIN civicrm_address contact_a_address ON (contact_a.id = contact_a_address.contact_id AND contact_a_address.is_primary = 1) ";
continue;
case 'contact_b_address':
$from .= " {$side} JOIN civicrm_address contact_b_address ON (contact_b.id = contact_b_address.contact_id AND contact_b_address.is_primary = 1) ";
continue;
default:
//dsm("TODO: form clause moet nog geïmplementeerd worden voor $name");
continue;
//.........这里部分代码省略.........