1.20.x select.inc public SelectQueryExtender::addExpression($expression, $alias = NULL, $arguments = array())

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.


$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

string|NULL: The unique alias that was assigned for this expression.

Overrides SelectQueryInterface::addExpression


includes/database/select.inc, line 749


The base extender class for Select queries.


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