function Select::orderRandom

Same name in this branch
  1. 8.9.x core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::orderRandom()
Same name in other branches
  1. 9 core/modules/pgsql/src/Driver/Database/pgsql/Select.php \Drupal\pgsql\Driver\Database\pgsql\Select::orderRandom()
  2. 9 core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::orderRandom()
  3. 10 core/modules/pgsql/src/Driver/Database/pgsql/Select.php \Drupal\pgsql\Driver\Database\pgsql\Select::orderRandom()
  4. 10 core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::orderRandom()
  5. 11.x core/modules/pgsql/src/Driver/Database/pgsql/Select.php \Drupal\pgsql\Driver\Database\pgsql\Select::orderRandom()
  6. 11.x core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::orderRandom()

Overrides Select::orderRandom

File

core/lib/Drupal/Core/Database/Driver/pgsql/Select.php, line 17

Class

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

Namespace

Drupal\Core\Database\Driver\pgsql

Code

public function orderRandom() {
    $alias = $this->addExpression('RANDOM()', 'random_field');
    $this->orderBy($alias);
    return $this;
}

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