本文整理汇总了PHP中DBManager::concat方法的典型用法代码示例。如果您正苦于以下问题:PHP DBManager::concat方法的具体用法?PHP DBManager::concat怎么用?PHP DBManager::concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager::concat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRelateJoin
/**
* @param array $field_def
* @param string $joinTableAlias
* @param bool $withIdName
* @return array|bool
*/
public function getRelateJoin($field_def, $joinTableAlias, $withIdName = true)
{
if (empty($field_def['type']) || $field_def['type'] != 'relate') {
return false;
}
$rel_mod = BeanFactory::getBean($field_def['module']);
if (!$rel_mod) {
return false;
}
$rel_table = $rel_mod->table_name;
$name_field = '';
if (isset($rel_mod->field_defs['name'])) {
$name_field_def = $rel_mod->field_defs['name'];
if (isset($name_field_def['db_concat_fields'])) {
$name_field = $this->db->concat($joinTableAlias, $name_field_def['db_concat_fields']);
} elseif (!empty($rel_mod->field_defs['name']['source']) && $rel_mod->field_defs['name']['source'] == 'non-db' && !empty($field_def['rname'])) {
$name_field = "{$joinTableAlias}." . $field_def['rname'];
} else {
$name_field = "{$joinTableAlias}.name";
}
}
$tableName = isset($field_def['custom_module']) ? "{$this->bean->table_name}_cstm" : $this->bean->table_name;
$relID = $field_def['id_name'];
$ret_array['rel_table'] = $rel_table;
$ret_array['name_field'] = $name_field;
$ret_array['select'] = ($withIdName ? ", {$tableName}.{$relID}" : '') . ", {$name_field} {$field_def['name']} ";
$ret_array['from'] = " LEFT JOIN {$rel_table} {$joinTableAlias} ON {$tableName}.{$relID} = {$joinTableAlias}.id" . " AND {$joinTableAlias}.deleted=0 ";
return $ret_array;
}
示例2: getRelateFieldQuery
/**
* Composes SELECT statement for fetching data of a relate field
*
* @param array $field_def Relate field definition
* @param string $joinTableAlias Alias for joined table
*
* @return array
*/
public function getRelateFieldQuery($field_def, $joinTableAlias, $selectedFields = array())
{
global $locale;
$name = $field_def['name'];
$rname = isset($field_def['rname']) ? $field_def['rname'] : 'name';
$joinCustomTableAlias = $joinTableAlias . '_cstm';
$fields = $sort_fields = array();
$has_custom_fields = false;
if (isset($this->field_defs[$rname])) {
$rname_field_def = $this->field_defs[$rname];
if (isset($rname_field_def['type']) && $rname_field_def['type'] == 'fullname') {
$format_fields = $locale->getNameFormatFields($this);
foreach ($format_fields as $format_field) {
$is_custom = $this->is_custom_field($format_field);
if ($is_custom) {
$joinAlias = $joinCustomTableAlias;
$has_custom_fields = true;
} else {
$joinAlias = $joinTableAlias;
}
$alias = $this->getRelateAlias($name, $format_field);
$fields[$alias] = $joinAlias . '.' . $format_field;
}
if (!empty($rname_field_def['sort_on'])) {
if ($joinTableAlias) {
$fields[$name] = $joinTableAlias . '.' . $rname_field_def['sort_on'];
} else {
$fields[$name] = $rname_field_def['sort_on'];
}
}
} elseif (isset($rname_field_def['db_concat_fields'])) {
$fields[$name] = $this->db->concat($joinTableAlias, $rname_field_def['db_concat_fields']);
} else {
$fields[$name] = $rname;
if ($joinTableAlias) {
$fields[$name] = $joinTableAlias . '.' . $fields[$name];
}
}
$sort_fields = $this->getRelateSortColumns($rname_field_def, $joinTableAlias, $joinCustomTableAlias, $has_custom_fields);
}
$parts = array();
foreach ($fields as $alias => $field) {
if (!in_array($alias, $selectedFields)) {
$parts[] = $field . ' ' . $alias;
}
}
$select = implode(', ', $parts);
if ($has_custom_fields) {
$join = ' LEFT JOIN ' . $this->get_custom_table_name() . ' ' . $joinCustomTableAlias . ' ON ' . $joinCustomTableAlias . '.id_c = ' . $joinTableAlias . '.id';
} else {
$join = '';
}
return array('select' => $select, 'join' => $join, 'fields' => $fields, 'sort_fields' => $sort_fields);
}
示例3: getRelatedFields
function getRelatedFields($module, $id, $fields, $return_array = false)
{
if (empty($GLOBALS['beanList'][$module])) {
return '';
}
$object = BeanFactory::getObjectName($module);
VardefManager::loadVardef($module, $object);
if (empty($GLOBALS['dictionary'][$object]['table'])) {
return '';
}
$table = $GLOBALS['dictionary'][$object]['table'];
$query = 'SELECT id';
foreach ($fields as $field => $alias) {
if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])) {
$query .= ' ,' . $this->db->concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) . ' as ' . $alias;
} else {
if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) || $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db")) {
$query .= ' ,' . $table . '.' . $field . ' as ' . $alias;
}
}
if (!$return_array) {
$this->{$alias} = '';
}
}
if ($query == 'SELECT id' || empty($id)) {
return '';
}
if (isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) {
$query .= " , " . $table . ".assigned_user_id owner";
} else {
if (isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) {
$query .= " , " . $table . ".created_by owner";
}
}
$query .= ' FROM ' . $table . ' WHERE deleted=0 AND id=';
$result = $GLOBALS['db']->query($query . "'{$id}'");
$row = $GLOBALS['db']->fetchByAssoc($result);
if ($return_array) {
return $row;
}
$owner = empty($row['owner']) ? '' : $row['owner'];
foreach ($fields as $alias) {
$this->{$alias} = !empty($row[$alias]) ? $row[$alias] : '';
$alias = $alias . '_owner';
$this->{$alias} = $owner;
$a_mod = $alias . '_mod';
$this->{$a_mod} = $module;
}
}