8.3.x SelectInterface.php public SelectInterface::addExpression($expression, $alias = NULL, $arguments = [])
8.0.x SelectInterface.php public SelectInterface::addExpression($expression, $alias = NULL, $arguments = array())
8.1.x SelectInterface.php public SelectInterface::addExpression($expression, $alias = NULL, $arguments = array())
8.2.x SelectInterface.php public SelectInterface::addExpression($expression, $alias = NULL, $arguments = array())
8.4.x SelectInterface.php public SelectInterface::addExpression($expression, $alias = NULL, $arguments = [])

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.

2 methods override SelectInterface::addExpression()
Select::addExpression in core/lib/Drupal/Core/Database/Query/Select.php
Adds an expression to the list of "fields" to be SELECTed.
SelectExtender::addExpression in core/lib/Drupal/Core/Database/Query/SelectExtender.php
Adds an expression to the list of "fields" to be SELECTed.

File

core/lib/Drupal/Core/Database/Query/SelectInterface.php, line 238

Class

SelectInterface
Interface definition for a Select Query object.

Namespace

Drupal\Core\Database\Query

Code

public function addExpression($expression, $alias = NULL, $arguments = array());