Skip navigation
Help

_field_sql_storage_query_field_conditions

7 field_sql_storage.module _field_sql_storage_query_field_conditions(EntityFieldQuery $query, SelectQuery $select_query, $conditions, $table_aliases, $column_callback)

Adds field (meta) conditions to the given query objects respecting groupings.

Parameters

EntityFieldQuery $query: The field query object to be processed.

SelectQuery $select_query: The SelectQuery that should get grouping conditions.

condtions: The conditions to be added.

$table_aliases: An associative array of table aliases keyed by field index.

$column_callback: A callback that should return the column name to be used for the field conditions. Accepts a field name and a field column name as parameters.

1 call to _field_sql_storage_query_field_conditions()

1 string reference to '_field_sql_storage_query_field_conditions'

File

drupal/modules/field/modules/field_sql_storage/field_sql_storage.module, line 594
Default implementation of the field storage API.

Code

function _field_sql_storage_query_field_conditions(EntityFieldQuery $query, SelectQuery $select_query, $conditions, $table_aliases, $column_callback) {
  $groups = &drupal_static(__FUNCTION__, array());
  foreach ($conditions as $key => $condition) {
    $table_alias = $table_aliases[$key];
    $field = $condition['field'];
    // Add the specified condition.
    $sql_field = "$table_alias." . $column_callback($field['field_name'], $condition['column']);
    $query->addCondition($select_query, $sql_field, $condition);
    // Add delta / language group conditions.
    foreach (array('delta', 'language') as $column) {
      if (isset($condition[$column . '_group'])) {
        $group_name = $condition[$column . '_group'];
        if (!isset($groups[$column][$group_name])) {
          $groups[$column][$group_name] = $table_alias;
        }
        else {
          $select_query->where("$table_alias.$column = " . $groups[$column][$group_name] . ".$column");
        }
      }
    }
  }
}