Permalink
Browse files

Fixed sorting

  • Loading branch information...
1 parent 419efa4 commit 19b3b91238792be48976849fe85ab96f9e7f39b0 @nickdunn nickdunn committed Mar 28, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 fields/field.time.php
View
@@ -29,10 +29,13 @@ function canPrePopulate(){
return true;
}
- public function buildSortingSQL(&$joins, &$where, &$sort, $order='ASC', $useIDFieldForSorting=false){
- $sort_field = (!$useIDFieldForSorting ? 'ed' : 't' . $this->get('id'));
- $joins .= "INNER JOIN `tbl_entries_data_".$this->get('id')."` AS `$sort_field` ON (`e`.`id` = `$sort_field`.`entry_id`) ";
- $sort .= (strtolower($order) == 'random' ? 'RAND()' : "`$sort_field`.`seconds` $order");
+ public function buildSortingSQL(&$joins, &$where, &$sort, $order='ASC'){
+ if(in_array(strtolower($order), array('random', 'rand'))) {
+ $sort = 'ORDER BY RAND()';
+ } else {
+ $joins .= "LEFT OUTER JOIN `tbl_entries_data_".$this->get('id')."` AS `ed` ON (`e`.`id` = `ed`.`entry_id`) ";
+ $sort .= "ORDER BY `ed`.`seconds` $order";
+ }
}
function groupRecords($records){

0 comments on commit 19b3b91

Please sign in to comment.