diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-12 23:08:00 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-12 23:08:00 +0000 |
commit | 26847773312887a4a982e4afd457b3da5fced384 (patch) | |
tree | ed9322af765681eccc195959bb62929dcae9604d /engine/lib/entities.php | |
parent | da90ff55725a9118ce6111ab2b6371650bf78ade (diff) | |
download | elgg-26847773312887a4a982e4afd457b3da5fced384.tar.gz elgg-26847773312887a4a982e4afd457b3da5fced384.tar.bz2 |
Fixes #2906. Added elgg_sql_reverse_order_by() and wired it up to ege() and ega(). Pass 'reverse_order_by' => true in option arrays.
git-svn-id: http://code.elgg.org/elgg/trunk@8184 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r-- | engine/lib/entities.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 4a1e496ec..7ab25de88 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -708,6 +708,8 @@ function get_entity($guid) { * * order_by => NULL (time_created desc)|STR SQL order by clause * + * reverse_order_by => BOOL Reverse the default order by clause + * * limit => NULL (10)|INT SQL limit clause * * offset => NULL (0)|INT SQL offset clause @@ -755,6 +757,7 @@ function elgg_get_entities(array $options = array()) { 'created_time_lower' => ELGG_ENTITIES_ANY_VALUE, 'created_time_upper' => ELGG_ENTITIES_ANY_VALUE, + 'reverse_order_by' => false, 'order_by' => 'e.time_created desc', 'group_by' => ELGG_ENTITIES_ANY_VALUE, 'limit' => 10, @@ -860,6 +863,12 @@ function elgg_get_entities(array $options = array()) { // Add access controls $query .= get_access_sql_suffix('e'); + + // reverse order by + if ($options['reverse_order_by']) { + $options['order_by'] = elgg_sql_reverse_order_by_clause($options['order_by']); + } + if (!$options['count']) { if ($options['group_by'] = sanitise_string($options['group_by'])) { $query .= " GROUP BY {$options['group_by']}"; |