From 504e579f97b601634015172bb0ed01fd08578ee7 Mon Sep 17 00:00:00 2001 From: icewing Date: Thu, 12 Jun 2008 13:48:42 +0000 Subject: Last commit for now git-svn-id: https://code.elgg.org/elgg/trunk@892 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/statistics.php | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/statistics.php b/engine/lib/statistics.php index 3adebd0b6..85a59b0af 100644 --- a/engine/lib/statistics.php +++ b/engine/lib/statistics.php @@ -1,7 +1,8 @@ \ No newline at end of file + + + // number of users + + // Number of objects broken down into type + + // who's online now + + /** + * Return an array reporting the number of various entities in the system. + * + * @return array + */ + function get_entity_statistics() + { + global $CONFIG; + + $entity_stats = array(); + + // Get a list of major types + $types = get_data("SELECT distinct e.type,s.subtype,e.subtype as subtype_id from {$CONFIG->dbprefix}entities e left join {$CONFIG->dbprefix}entity_subtypes s on e.subtype=s.id"); + foreach ($types as $type) { + if (!is_array($entity_stats[$type->type])) + $entity_stats[$type->type] = array(); // assume there are subtypes for now + + $query = "SELECT count(*) as count from {$CONFIG->dbprefix}entities where type='{$type->type}'"; + if ($type->subtype) $query.= " and subtype={$type->subtype_id}"; + $subtype_cnt = get_data($query); + + if ($type->subtype) + $entity_stats[$type->type][$type->subtype] = $subtype_cnt->count; + else + $entity_stats[$type->type]['__base__'] = $subtype_cnt->count; + } + + return $entity_stats; + } +?> -- cgit v1.2.3