aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/metadata.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index da189fe30..ebc425f17 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -602,10 +602,11 @@
* @param int $offset
* @param string $order_by Optional ordering.
* @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
- * @param true|false $count If set to true, returns the total number of entities rather than a list. (Default: false)
+ * @param true|false $count If set to true, returns the total number of entities rather than a list. (Default: false)
+ * @param string $meta_array_operator Operator used for joining the metadata array together
* @return int|array List of ElggEntities, or the total number if count is set to false
*/
- function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false)
+ function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false, $meta_array_operator = 'and')
{
global $CONFIG;
@@ -616,17 +617,21 @@
$where = array();
$mindex = 1;
- $join = "";
+ $join = "";
+ $metawhere = array();
+ $meta_array_operator = sanitise_string($meta_array_operator);
foreach($meta_array as $meta_name => $meta_value) {
$meta_n = get_metastring_id($meta_name);
$meta_v = get_metastring_id($meta_value);
$join .= " JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid ";
- if ($meta_name!=="")
+ /*if ($meta_name!=="")
$where[] = "m{$mindex}.name_id='$meta_n'";
if ($meta_value!=="")
- $where[] = "m{$mindex}.value_id='$meta_v'";
+ $where[] = "m{$mindex}.value_id='$meta_v'";*/
+ $metawhere[] = "(m{$mindex}.name_id='$meta_n' AND m{$mindex}.value_id='$meta_v')";
$mindex++;
- }
+ }
+ $where[] = "(".implode($meta_array_operator, $metawhere).")";
$entity_type = sanitise_string($entity_type);
$entity_subtype = get_subtype_id($entity_type, $entity_subtype);