From dcc51ec479e90c5f0651441519801ccedb018ee4 Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Tue, 20 Sep 2016 14:16:22 -0500 Subject: [PATCH] Docs - sort by random instructions Added instructions for sorting per database type. `RAND()` throws errors in PostgreSQL and SQLite --- .../en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md b/docs/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md index 21acfce88..b02ef017c 100644 --- a/docs/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md +++ b/docs/en/02_Developer_Guides/00_Model/01_Data_Model_and_ORM.md @@ -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