Hi,
I would like to get all object entities which do not have a metadata of some name (let's say mimetype).
I guess I should use the function elgg_get_entities_from_metadata. I know how I can get entities with some metadata - for example with mimetype=image/jpeg, but I do not know how to get all entities without the mimetype at all? (mimetype is of course just an example).
Anybody could help?
Regards
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.
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Kevin Jardine@kevin
Kevin Jardine - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Kevin Jardine@kevin
Kevin Jardine - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Chetan Sharma@openminds
Chetan Sharma - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Robert Koziol@rkoziol7
Robert Koziol - 0 likes
You must log in to post replies.metadata_name_value_pairs
I could be wrong, but I believe that there is no easy way to do that.
You could get all the entities of the appropriate type and subtype and then check it yourself in a loop.
Obviously that could be large, so if you can constrain to a specific owner or container that would be better.
Alternatively, if you wanted to write a custom join and where clause, you could do a LEFT JOIN and then check if the result was NULL in the where clause.
Perhaps the easiest way to do this going forward with no custom coding would be to have a specific default value that would be used if the data was not defined eg. "*NONE*". So you would have something to check.
So core code is incorrect ? surely this is how elgg_get_entities_from_metadata is meant to work ;-) * metadata_name_value_pairs => NULL|ARR (name => 'name', value => 'value', 'operand' => '=', 'case_sensitive' => TRUE) entries.
Dhrup, the original poster wanted to check for the nonexistence of a value. elgg_get_entities_from_metadata checks for the existence of a value.
@@Kevin -->
ahem..... I "used the source..."
this works for me to fetch entities with non-existence of metadata ;-)
$objectsAlpha =
elgg_list_entities_from_metadata
(
array
(
metadata_name_value_pairs
=> array
(
'name' => "name_initial",
'value' => "A",
'operand' => " != ",
'case_sensitive' => FALSE
)
, 'types' => "group"
, 'limit' => 10
, 'full_view' => FALSE
)
)
;
hmmmm, I think he wants to know how to get he entities if the metadata doesn't even exists..
Like what if "name_initial" doesn't even exists in the system.. eg
So in this case only those entities how satisfy the condition will have the metadata other will now even have it.
LOLZ ;-)
"name_initial" is metadata on my Groups AlphaSort customization ;-X
and so.. it exists on my test site.
I think he asked for "get all object entities which do not have a metadata of some name (let's say mimetype)..."
-->
wants to fetch entities by metadata where metadata value != "blahblah"...
Which is exactly what I coded in the API call parms and.. it works LOLZ ;-)
Elgg API has provision to specify <metadata> <operator> <value>
read up in engine/lic/ metadata.php for the calling sequence -
all I did was to code as the API allows.
If he really want to fetch enbtities which do not have metadata named as such...
Then he will have to copy the typical metadata query generated by metadata.php code and
re-hash a new very custom call on the meta data/strings table probably using (L/R) outer JOIN and work back to the entities that do not have that metadata as named -- a somewhat messy join, join, join...
I do that believe he wants to fetch by metadata where entitiy's metadata value is not equal to "some-value" -- but **he needs to come back here and qualify his intent while we go on with out philosophicals on the Elgg API ;-P
Well the discussion is very interesting :)
I was going to get entities without some metadata at all (not with metadata 'mimetype' != 'some value', but those without metadata 'mimetype' of any value). In other words (actually DhrupDeScoop's words) I was interested in fetching entities which do not have metadata named as'mimetype'.
I have discovered a workaround of my problem. I will not place it here because it has nothing to do with fetching entities and it is rather 'a brutal force' solution.
However it is good to hear that I should probably write my own query to achieve that. Maybe it will be useful in the future.
Thanks for all your suggestions :)