public function Select::orderRandom in Drupal driver for SQL Server and SQL Azure 8
Same name and namespace in other branches
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Select.php \Drupal\Driver\Database\sqlsrv\Select::orderRandom()
- 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Select.php \Drupal\Driver\Database\sqlsrv\Select::orderRandom()
Override of SelectQuery::orderRandom() for SQL Server.
It seems that sorting by RAND() doesn't actually work, this is a less then elegant workaround.
@status tested
Overrides Select::orderRandom
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Select.php, line 429 - Definition of Drupal\Driver\Database\sqlsrv\Select
Class
Namespace
Drupal\Driver\Database\sqlsrvCode
public function orderRandom() {
$alias = $this
->addExpression('NEWID()', 'random_field');
$this
->orderBy($alias);
return $this;
}