From 05746e64f2e1250e4cce2052d601739028fc6f2e Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Wed, 17 Aug 2005 23:16:34 +0000 Subject: [PATCH] Fixing a postgres error. You can't sort by a field that isn't in the select list when you have distinct --- lib/datalib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/datalib.php b/lib/datalib.php index 128d09d786a..e12ea2a6878 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1963,7 +1963,14 @@ function get_group_users($groupid, $sort='u.lastaccess DESC', $exceptions='', $f } else { $except = ''; } - return get_records_sql("SELECT DISTINCT $fields + // in postgres, you can't have things in sort that aren't in the select, so... + $extrafield = str_replace('ASC','',$sort); + $extrafield = str_replace('DESC','',$sort); + $extrafield = trim($extrafield); + if (!empty($extrafield)) { + $extrafield = ','.$extrafield; + } + return get_records_sql("SELECT DISTINCT $fields $extrafield FROM {$CFG->prefix}user u, {$CFG->prefix}groups_members m WHERE m.groupid = '$groupid'