From 1770180c274d981f2dcf8a4791753de54652f51b Mon Sep 17 00:00:00 2001 From: brettp Date: Thu, 29 Oct 2009 21:21:30 +0000 Subject: Deprecated get_entities_from_relationships_and_meta(). git-svn-id: http://code.elgg.org/elgg/trunk@3603 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/metadata.php | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'engine/lib/metadata.php') diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 1d6fc59f4..ea1ce412d 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -571,23 +571,25 @@ function elgg_get_entities_from_metadata(array $options = array()) { $clauses = elgg_get_entity_metadata_where_sql('e', $options['names'], $options['values'], $options['name_value_pairs'], $options['name_value_pairs_operator'], $options['case_sensitive']); - // merge wheres to pass to get_entities() - if (isset($options['wheres']) && !is_array($options['wheres'])) { - $options['wheres'] = array($options['wheres']); - } elseif (!isset($options['wheres'])) { - $options['wheres'] = array(); - } + if ($clauses) { + // merge wheres to pass to get_entities() + if (isset($options['wheres']) && !is_array($options['wheres'])) { + $options['wheres'] = array($options['wheres']); + } elseif (!isset($options['wheres'])) { + $options['wheres'] = array(); + } - $options['wheres'][] = $clauses['wheres']; + $options['wheres'] = array_merge($options['wheres'], $clauses['wheres']); - // merge joins to pass to get_entities() - if (isset($options['joins']) && !is_array($options['joins'])) { - $options['joins'] = array($options['joins']); - } elseif (!isset($options['joins'])) { - $options['joins'] = array(); - } + // merge joins to pass to get_entities() + if (isset($options['joins']) && !is_array($options['joins'])) { + $options['joins'] = array($options['joins']); + } elseif (!isset($options['joins'])) { + $options['joins'] = array(); + } - $options['joins'] = array_merge($options['joins'], $clauses['joins']); + $options['joins'] = array_merge($options['joins'], $clauses['joins']); + } return elgg_get_entities($options); } @@ -629,6 +631,8 @@ function elgg_get_entity_metadata_where_sql($table, $names = NULL, $values = NUL 'wheres' => array() ); + $wheres = array(); + // get names wheres and joins $names_where = ''; if ($names !== NULL) { @@ -758,7 +762,9 @@ function elgg_get_entity_metadata_where_sql($table, $names = NULL, $values = NUL } } - $return['wheres'] = implode(' OR ', $wheres); + if ($where = implode(' OR ', $wheres)) { + $return['wheres'][] = "($where)"; + } return $return; } -- cgit v1.2.3