While using elgg_get_entities_from_metadata() function to retrieve entities having a particular set of metadata name-value combinations, I have encountered a situation in which I have to use certain metadatas conditions(name-value pairs) with OR operator, ANDed with some more metadata name-value pairs. But since the syntax states that we use the two properties metadata_name_value_pairs and operator separately, I cant see a way to impose such condition.
$return = array();
$options = array(
'type' => 'user',
'metadata_name_value_pairs' => array(array('name'=>'Name1','value'=>'Value1','operand'=>'='),
array('name'=>'Name2', 'value'=>'Value2',operand=>'='),
array('name'=>'Name3', 'value'=>'Value3',operand=>'=')),
'metadata_name_value_pairs_operator'=>'OR', /* How to use this operator for 1st two name value pairs and ANDed with 3rd name value pair*/
'limit'=>$limit,
'offset'=>$offset,
'count'=>$count,
);
$return = elgg_get_entities_from_metadata($options);
Please let me know, if there is some other way to do the same thing but with more control.
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.