function _field_sql_storage_tablealias in Drupal 7
Generates a table alias for a field data table.
The table alias is unique for each unique combination of field name (represented by $tablename), delta_group and language_group.
Parameters
$tablename: The name of the data table for this field.
$field_key: The numeric key of this field in this query.
$query: The EntityFieldQuery that is executed.
Return value
A string containing the generated table alias.
1 call to _field_sql_storage_tablealias()
- field_sql_storage_field_storage_query in modules/
field/ modules/ field_sql_storage/ field_sql_storage.module - Implements hook_field_storage_query().
File
- modules/
field/ modules/ field_sql_storage/ field_sql_storage.module, line 83 - Default implementation of the field storage API.
Code
function _field_sql_storage_tablealias($tablename, $field_key, EntityFieldQuery $query) {
// No conditions present: use a unique alias.
if (empty($query->fieldConditions[$field_key])) {
return $tablename . $field_key;
}
// Find the delta and language condition values and append them to the alias.
$condition = $query->fieldConditions[$field_key];
$alias = $tablename;
$has_group_conditions = FALSE;
foreach (array(
'delta',
'language',
) as $column) {
if (isset($condition[$column . '_group'])) {
$alias .= '_' . $column . '_' . $condition[$column . '_group'];
$has_group_conditions = TRUE;
}
}
// Return the alias when it has delta/language group conditions.
if ($has_group_conditions) {
return $alias;
}
// Return a unique alias in other cases.
return $tablename . $field_key;
}