You are here

protected function FuzzySearchService::getTableAlias in Fuzzy Search 7

Helper method for adding a field's table to a database query.

Parameters

array $field: The field information array. The "table" key should contain the table name to which a join should be made.

SelectQueryInterface $db_query: The database query used.

bool $newjoin: If TRUE, a join is done even if the table was already joined to in the query.

Return value

string The unique alias that was assigned for this table.

3 calls to FuzzySearchService::getTableAlias()
FuzzySearchService::createFilterCondition in includes/service.inc
Helper method for creating a condition for filtering search results.
FuzzySearchService::getFacets in includes/service.inc
Helper method for getting the facet values for a query.
FuzzySearchService::search in includes/service.inc
Executes a search on the server represented by this object.

File

includes/service.inc, line 1225

Class

FuzzySearchService
Search service class using the database for storing index information.

Code

protected function getTableAlias(array $field, SelectQueryInterface $db_query, $newjoin = FALSE) {
  if (!$newjoin) {
    foreach ($db_query
      ->getTables() as $alias => $info) {
      $table = $info['table'];
      if (is_scalar($table) && $table == $field['table']) {
        return $alias;
      }
    }
  }
  return $db_query
    ->join($field['table'], 't', 't.item_id = %alias.item_id');
}