You are here

public function Select::addExpression in Drupal 10

1 call to Select::addExpression()
Select::orderRandom in core/modules/pgsql/src/Driver/Database/pgsql/Select.php

File

core/modules/pgsql/src/Driver/Database/pgsql/Select.php, line 127

Class

Select
PostgreSQL implementation of \Drupal\Core\Database\Query\Select.

Namespace

Drupal\pgsql\Driver\Database\pgsql

Code

public function addExpression($expression, $alias = NULL, $arguments = []) {
  if (empty($alias)) {
    $alias = 'expression';
  }

  // This implements counting in the same manner as the parent method.
  $alias_candidate = $alias;
  $count = 2;
  while (!empty($this->expressions[$alias_candidate])) {
    $alias_candidate = $alias . '_' . $count++;
  }
  $alias = $alias_candidate;
  $this->expressions[$alias] = [
    'expression' => $expression,
    'alias' => $this->connection
      ->escapeAlias($alias_candidate),
    'arguments' => $arguments,
  ];
  return $alias;
}