diff options
author | Cash Costello <cash.costello@gmail.com> | 2012-07-06 18:22:32 -0400 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2012-07-06 18:22:32 -0400 |
commit | e9df0780e7499f983ccb9d346d202343aa1b2c18 (patch) | |
tree | 0ae39043e4a0e85e5af0ff2ecaea26a6759d1d3a /engine | |
parent | 1a3c2c3a1f5eacece62cd25a88d678df5aed65a5 (diff) | |
download | elgg-e9df0780e7499f983ccb9d346d202343aa1b2c18.tar.gz elgg-e9df0780e7499f983ccb9d346d202343aa1b2c18.tar.bz2 |
Fixes #3046 adds documentation for requesting entities that do not have metadata or relationships
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/metadata.php | 13 | ||||
-rw-r--r-- | engine/lib/relationships.php | 9 |
2 files changed, 21 insertions, 1 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 0ff3a43dc..77fa30e41 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -361,13 +361,24 @@ function elgg_enable_metadata(array $options) { * options available to elgg_get_entities(). Supports * the singular option shortcut. * - * NB: Using metadata_names and metadata_values results in a + * @note Using metadata_names and metadata_values results in a * "names IN (...) AND values IN (...)" clause. This is subtly * differently than default multiple metadata_name_value_pairs, which use * "(name = value) AND (name = value)" clauses. * * When in doubt, use name_value_pairs. * + * To ask for entities that do not have a metadata value, use a custom + * where clause like this: + * + * $options['wheres'][] = "NOT EXISTS ( + * SELECT 1 FROM {$dbprefix}metadata md + * WHERE md.entity_guid = e.guid + * AND md.name_id = $name_metastring_id + * AND md.value_id = $value_metastring_id)"; + * + * Note the metadata name and value has been denormalized in the above example. + * * @see elgg_get_entities * * @param array $options Array in format: diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index f50c4a485..09d541e22 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -239,6 +239,15 @@ function get_entity_relationships($guid, $inverse_relationship = FALSE) { * Also accepts all options available to elgg_get_entities() and * elgg_get_entities_from_metadata(). * + * To ask for entities that do not have a particulat relationship to an entity, + * use a custom where clause like the following: + * + * $options['wheres'][] = "NOT EXISTS ( + * SELECT 1 FROM {$db_prefix}entity_relationships + * WHERE guid_one = e.guid + * AND relationship = '$relationship' + * )"; + * * @see elgg_get_entities * @see elgg_get_entities_from_metadata * |