listing groups

I'm trying to list all groups, what would be a good a quick method? I'm trying to avoid a sql query to table *_groups_entity and use elgg api instead, but I don't find the right function

Thanks in advance

  • elgg_list_entities() will do it

  • Thank you very much.

    What I want to do is to avoid creating a group with the same name of another previously created. I understand that using elgg_list_entities() will force me to query the name of each entity I get. With lots of groups and lots of group creation request, checking that could lead to a database performance problem (one query to get the entities, and one more query for each entity to get its name and compare). I think what I look for is something with just one query that checks if there is already a group with the same name, and I'm now realizing a direct sql query will be required, more optimun but less elgg-ish

    I would appreciate if people here confirm my thoughts are right, or there is something in elgg API that could fit.

    Thank you