public function MySql::orderByRandom in Search API 8
Applies a random sort to the query.
Parameters
\Drupal\Core\Database\Query\SelectInterface $query: The search query.
Overrides GenericDatabase::orderByRandom
File
- modules/
search_api_db/ src/ DatabaseCompatibility/ MySql.php, line 57
Class
- MySql
- Represents a MySQL-based database.
Namespace
Drupal\search_api_db\DatabaseCompatibilityCode
public function orderByRandom(SelectInterface $query) {
$alias = $query
->addExpression('rand()', 'random_order_field');
$query
->orderBy($alias);
}