Thank you for your feedback. Yes I can do it with the existing API, but not efficencly.
Before creating a new group I want to check another group with the same name already exists. It if does do something (not an error) and if it does then create it.
I can query the guid of the groups and then query the name of each guid, it is fine, but with "zillions" of groups already created, and with "zillions" of requests for new groups it would overload the database. A simple SQL query could just check the name in the group table quickly, but I wanted to use the API instead, and simplequery() came handy.
(ok, I know there is the question of why I need zillions of groups and requests, that's another problem :)
Thank you!
As of 1.7 there is no way to get entities by name/title via the API, so you are correct to write your own SQL. We're looking into solutions for 1.8 that would allow sorting / retrieving entities by these attributes.
You should be able to do this through elgg_get_entities() by using a custom join and where clause.
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
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.