File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -794,8 +794,12 @@ protected function _buildOrderBy () {
794794 return ;
795795
796796 $ this ->_query .= " ORDER BY " ;
797- foreach ($ this ->_orderBy as $ prop => $ value )
798- $ this ->_query .= $ prop . " " . $ value . ", " ;
797+ foreach ($ this ->_orderBy as $ prop => $ value ) {
798+ if (strtolower (str_replace (" " , "" , $ prop )) == 'rand() ' )
799+ $ this ->_query .= "rand(), " ;
800+ else
801+ $ this ->_query .= $ prop . " " . $ value . ", " ;
802+ }
799803
800804 $ this ->_query = rtrim ($ this ->_query , ', ' ) . " " ;
801805 }
Original file line number Diff line number Diff line change @@ -254,8 +254,9 @@ $results = $db
254254``` php
255255$db->orderBy("id","asc");
256256$db->orderBy("login","Desc");
257+ $db->orderBy("RAND ()");
257258$results = $db->get('users');
258- // Gives: SELECT * FROM users ORDER BY id ASC,login DESC;
259+ // Gives: SELECT * FROM users ORDER BY id ASC,login DESC, RAND () ;
259260```
260261
261262### Grouping method
You can’t perform that action at this time.
0 commit comments