mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Docs - sort by random instructions
Added instructions for sorting per database type. `RAND()` throws errors in PostgreSQL and SQLite
This commit is contained in:
parent
32d1856d40
commit
dcc51ec479
@ -268,10 +268,11 @@ However you might have several entries with the same `FirstName` and would like
|
||||
'LastName'=>'ASC'
|
||||
));
|
||||
|
||||
You can also sort randomly.
|
||||
You can also sort randomly. Using the `DB` class, you can get the random sort method per database type.
|
||||
|
||||
:::php
|
||||
$players = Player::get()->sort('RAND()')
|
||||
$random = DB::get_conn()->random();
|
||||
$players = Player::get()->sort($random)
|
||||
|
||||
|
||||
## Filtering Results
|
||||
|
Loading…
x
Reference in New Issue
Block a user