The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Best way to retrieve the number of users with a specific secondary usergroup?
Is there any easy way to retrieve the amount of users who have a specific secondary usergroup? I need to be able to quickly retrieve a count, and want to know the most load-friendly way of doing it. (Without looping through the resultset to check if the groupid is in the array of membergroupids.)
Edit: for other people's reference here is how vbulletin does it: (I guess I'm all set.) Code:
// count secondary users $groupcounts = $db->query_read(" SELECT membergroupids, usergroupid FROM " . TABLE_PREFIX . "user WHERE membergroupids <> '' "); while ($groupcount = $db->fetch_array($groupcounts)) { $ids = fetch_membergroupids_array($groupcount, false); foreach ($ids AS $index => $value) { if ($groupcount['usergroupid'] != $value AND !empty($vbulletin->usergroupcache["$value"])) { $vbulletin->usergroupcache["$value"]['secondarycount']++; } } } |
#2
|
|||
|
|||
If you just want to have the count for a specific secondary usergroup, the following query (untested!) should also work:
[sql]SELECT COUNT(*) FROM user WHERE FIND_IN_SET(GROUPID, membergroupids);[/sql]Replace GROUPID with the group you are searching for. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|