function SelectQuery::addExpression

Overrides SelectQueryInterface::addExpression

2 calls to SelectQuery::addExpression()
SelectQuery::orderRandom in includes/database/select.inc
Orders the result set by a random value.
SelectQuery_pgsql::orderRandom in includes/database/pgsql/select.inc
Orders the result set by a random value.

File

includes/database/select.inc, line 1363

Class

SelectQuery
Query builder for SELECT statements.

Code

public function addExpression($expression, $alias = NULL, $arguments = array()) {
    if (empty($alias)) {
        $alias = 'expression';
    }
    $alias_candidate = $alias;
    $count = 2;
    while (!empty($this->expressions[$alias_candidate])) {
        $alias_candidate = $alias . '_' . $count++;
    }
    $alias = $alias_candidate;
    $this->expressions[$alias] = array(
        'expression' => $expression,
        'alias' => $alias,
        'arguments' => $arguments,
    );
    return $alias;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.