From a13322de6e1f130161b731384685c30f3d35d683 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 8 Dec 2010 03:13:35 +0000 Subject: Refs #1411: Added elgg_get_entity_from_relationship_count(). git-svn-id: http://code.elgg.org/elgg/trunk@7562 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/relationships.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'engine/lib/relationships.php') diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index f19c76e8b..3e129bc79 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -435,6 +435,22 @@ $fullview = true, $listtypetoggle = false, $pagination = true) { )); } +/** + * Gets the number of entities by a the number of entities related to them in a particular way. + * This is a good way to get out the users with the most friends, or the groups with the + * most members. + * + * @param array $options An options array compatible with + * elgg_get_entities_from_relationship() + * @return array + */ +function elgg_get_entities_from_relationship_count(array $options = array()) { + $options['selects'][] = "COUNT(e.guid) as total"; + $options['group_by'] = 'r.guid_two'; + $options['order_by'] = 'total desc'; + return elgg_get_entities_from_relationship($options); +} + /** * Gets the number of entities by a the number of entities related to them in a particular way. * This is a good way to get out the users with the most friends, or the groups with the @@ -563,7 +579,9 @@ $listtypetoggle = false, $pagination = true) { /** * Gets the number of entities by a the number of entities related to - * them in a particular way also constrained by metadata + * them in a particular way also constrained by metadata. + * + * @deprecated 1.8 * * @param string $relationship The relationship eg "friends_of" * @param int $relationship_guid The guid of the entity to use query -- cgit v1.2.3