public function GenericDatabase::orderByRandom in Search API 8
Applies a random sort to the query.
Parameters
\Drupal\Core\Database\Query\SelectInterface $query: The search query.
Overrides DatabaseCompatibilityHandlerInterface::orderByRandom
1 method overrides GenericDatabase::orderByRandom()
- MySql::orderByRandom in modules/
search_api_db/ src/ DatabaseCompatibility/ MySql.php - Applies a random sort to the query.
File
- modules/
search_api_db/ src/ DatabaseCompatibility/ GenericDatabase.php, line 75
Class
- GenericDatabase
- Represents any database for which no specifics are known.
Namespace
Drupal\search_api_db\DatabaseCompatibilityCode
public function orderByRandom(SelectInterface $query) {
$alias = $query
->addExpression('random()', 'random_order_field');
$query
->orderBy($alias);
}