W3cubDocs

/Drupal 8

function QueryAggregate::createSqlAlias

QueryAggregate::createSqlAlias($field, $sql_field)

Builds a sql alias as expected in the result.

Parameters

string $field: The field as passed in by the caller.

string $sql_field: The sql field as returned by getSqlField.

Return value

string The SQL alias expected in the return value. The dots in $sql_field are replaced with underscores and if a default fallback to .value happened, the _value is stripped.

File

core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php, line 154

Class

QueryAggregate
The SQL storage entity query aggregate class.

Namespace

Drupal\Core\Entity\Query\Sql

Code

function createSqlAlias($field, $sql_field) {
  $alias = str_replace('.', '_', $sql_field);
  // If the alias contains of field_*_value remove the _value at the end.
  if (substr($alias, 0, 6) === 'field_' && substr($field, -6) !== '_value' && substr($alias, -6) === '_value') {
    $alias = substr($alias, 0, -6);
  }
  return $alias;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Query!Sql!QueryAggregate.php/function/QueryAggregate::createSqlAlias/8.1.x