You are here

public function SelectExtender::addExpression in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Database/Query/SelectExtender.php \Drupal\Core\Database\Query\SelectExtender::addExpression()

Adds an expression to the list of "fields" to be SELECTed.

An expression can be any arbitrary string that is valid SQL. That includes various functions, which may in some cases be database-dependent. This method makes no effort to correct for database-specific functions.

Parameters

$expression: The expression string. May contain placeholders.

$alias: The alias for this expression. If not specified, one will be generated automatically in the form "expression_#". The alias will be checked for uniqueness, so the requested alias may not be the alias that is assigned in all cases.

$arguments: Any placeholder arguments needed for this expression.

Return value

The unique alias that was assigned for this expression.

Overrides SelectInterface::addExpression

1 call to SelectExtender::addExpression()
SearchQuery::execute in core/modules/search/src/SearchQuery.php
Executes the search.

File

core/lib/Drupal/Core/Database/Query/SelectExtender.php, line 351
Contains \Drupal\Core\Database\Query\SelectExtender.

Class

SelectExtender
The base extender class for Select queries.

Namespace

Drupal\Core\Database\Query

Code

public function addExpression($expression, $alias = NULL, $arguments = array()) {
  return $this->query
    ->addExpression($expression, $alias, $arguments);
}