本文整理汇总了PHP中DynamicField::getRelateJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP DynamicField::getRelateJoin方法的具体用法?PHP DynamicField::getRelateJoin怎么用?PHP DynamicField::getRelateJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicField
的用法示例。
在下文中一共展示了DynamicField::getRelateJoin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetRelateJoin
public function testGetRelateJoin()
{
require_once 'modules/DynamicFields/DynamicField.php';
$dynamicField = new DynamicField();
$account = new Account();
$dynamicField->bean = $account;
$field_def = array('dependency' => '', 'required' => '', 'source' => 'non-db', 'name' => 'm1_related_c', 'vname' => 'LBL_M1_RELATED', 'type' => 'relate', 'massupdate' => 0, 'default' => '', 'comments' => '', 'help' => '', 'importable' => true, 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => 0, 'audited' => '', 'reportable' => 1, 'calculated' => '', 'len' => 255, 'size' => 20, 'id_name' => 'def_m1_id_c', 'ext2' => 'Accounts', 'module' => 'Accounts', 'rname' => 'name', 'quicksearch' => 'enabled', 'studio' => 'visible', 'id' => 'def_M1m1_related_c', 'custom_module' => 'Accounts');
$joinTableAlias = 'jt1';
$relatedJoinInfo = $dynamicField->getRelateJoin($field_def, $joinTableAlias);
//echo var_export($relatedJoinInfo, true);
$this->assertEquals(', accounts_cstm.def_m1_id_c, jt1.name m1_related_c ', $relatedJoinInfo['select']);
}
示例2: create_new_list_query
//.........这里部分代码省略.........
//layout customization.. this happens in subpanel customizations, use case, from the contacts subpanel
//in opportunities module remove the contact_role/opportunity_role field.
$process_field = true;
if (isset($data['relationship_fields']) and !empty($data['relationship_fields'])) {
foreach ($data['relationship_fields'] as $field_name) {
if (!isset($fields[$field_name])) {
$process_field = false;
}
}
}
if (!$process_field) {
continue;
}
if ((!isset($data['source']) || $data['source'] == 'db') && (!empty($alias) || !empty($filter))) {
$ret_array['select'] .= ", {$this->table_name}.{$field} {$alias}";
$selectedFields["{$this->table_name}.{$field}"] = true;
} else {
if ((!isset($data['source']) || $data['source'] == 'custom_fields') && (!empty($alias) || !empty($filter))) {
//add this column only if it has NOT already been added to select statement string
$colPos = strpos($ret_array['select'], "{$this->table_name}" . "_cstm" . ".{$field}");
if (!$colPos || $colPos < 0) {
$ret_array['select'] .= ", {$this->table_name}" . "_cstm" . ".{$field} {$alias}";
}
$selectedFields["{$this->table_name}.{$field}"] = true;
}
}
if ($data['type'] != 'relate' && isset($data['db_concat_fields'])) {
$ret_array['select'] .= ", " . $this->db->concat($this->table_name, $data['db_concat_fields']) . " as {$field}";
$selectedFields[$this->db->concat($this->table_name, $data['db_concat_fields'])] = true;
}
//Custom relate field or relate fields built in module builder which have no link field associated.
if ($data['type'] == 'relate' && (isset($data['custom_module']) || isset($data['ext2']))) {
$joinTableAlias = 'jt' . $jtcount;
$relateJoinInfo = $this->custom_fields->getRelateJoin($data, $joinTableAlias, false);
$ret_array['select'] .= $relateJoinInfo['select'];
$ret_array['from'] .= $relateJoinInfo['from'];
//Replace any references to the relationship in the where clause with the new alias
//If the link isn't set, assume that search used the local table for the field
$searchTable = isset($data['link']) ? $relateJoinInfo['rel_table'] : $this->table_name;
$field_name = $relateJoinInfo['rel_table'] . '.' . !empty($data['name']) ? $data['name'] : 'name';
$where = preg_replace('/(^|[\\s(])' . $field_name . '/', '${1}' . $relateJoinInfo['name_field'], $where);
$jtcount++;
}
//Parent Field
if ($data['type'] == 'parent') {
//See if we need to join anything by inspecting the where clause
$match = preg_match('/(^|[\\s(])parent_(\\w+)_(\\w+)\\.name/', $where, $matches);
if ($match) {
$joinTableAlias = 'jt' . $jtcount;
$joinModule = $matches[2];
$joinTable = $matches[3];
$localTable = $this->table_name;
if (!empty($data['custom_module'])) {
$localTable .= '_cstm';
}
global $beanFiles, $beanList, $module;
require_once $beanFiles[$beanList[$joinModule]];
$rel_mod = new $beanList[$joinModule]();
$nameField = "{$joinTableAlias}.name";
if (isset($rel_mod->field_defs['name'])) {
$name_field_def = $rel_mod->field_defs['name'];
if (isset($name_field_def['db_concat_fields'])) {
$nameField = $this->db->concat($joinTableAlias, $name_field_def['db_concat_fields']);
}
$ret_array['select'] .= ", {$nameField} {$data['name']} ";
$ret_array['from'] .= " LEFT JOIN {$joinTable} {$joinTableAlias}\n ON {$localTable}.{$data['id_name']} = {$joinTableAlias}.id";