protected function Database::getTableAlias in Search API 8
Joins a field's table into a database select query.
Parameters
array $field: The field information array. The "table" key should contain the table name to which a join should be made.
\Drupal\Core\Database\Query\SelectInterface $db_query: The database query used.
bool $new_join: (optional) If TRUE, a join is done even if the table was already joined to in the query.
string $join: (optional) The join method to use. Must be a method of the $db_query. Normally, "join", "innerJoin", "leftJoin" and "rightJoin" are supported.
string|null $additional_on: (optional) If given, an SQL string with additional conditions for the ON clause of the join.
array $on_arguments: (optional) Additional arguments for the ON clause.
Return value
string The alias for the field's table.
3 calls to Database::getTableAlias()
- Database::createDbCondition in modules/
search_api_db/ src/ Plugin/ search_api/ backend/ Database.php - Creates a database query condition for a given search filter.
- Database::getFacets in modules/
search_api_db/ src/ Plugin/ search_api/ backend/ Database.php - Computes facets for a search query.
- Database::setQuerySort in modules/
search_api_db/ src/ Plugin/ search_api/ backend/ Database.php - Adds the appropriate "ORDER BY" statements to a search database query.
File
- modules/
search_api_db/ src/ Plugin/ search_api/ backend/ Database.php, line 2343
Class
- Database
- Indexes and searches items using the database.
Namespace
Drupal\search_api_db\Plugin\search_api\backendCode
protected function getTableAlias(array $field, SelectInterface $db_query, $new_join = FALSE, $join = 'leftJoin', $additional_on = NULL, array $on_arguments = []) {
if (!$new_join) {
foreach ($db_query
->getTables() as $alias => $info) {
$table = $info['table'];
if (is_scalar($table) && $table == $field['table']) {
return $alias;
}
}
}
$condition = 't.item_id = %alias.item_id';
if ($additional_on) {
$condition .= ' AND ' . $additional_on;
}
return $db_query
->{$join}($field['table'], 't', $condition, $on_arguments);
}