aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/metadata.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 2f6087f8a..01a981945 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -255,6 +255,7 @@
* Return the metadata values that match your query.
*
* @param string $meta_name
+ * @return mixed either a value, an array of ElggMetadata or false.
*/
function get_metadata_byname($entity_guid, $meta_name)
{
@@ -264,8 +265,14 @@
$entity_guid = (int)$entity_guid;
$access = get_access_list();
- echo "SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid=$entity_guid and m.name_id='$meta_name' and (m.access_id in {$access} or (m.access_id = 0 and m.owner_guid = {$_SESSION['id']}))";
- return get_data("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid=$entity_guid and m.name_id='$meta_name' and (m.access_id in {$access} or (m.access_id = 0 and m.owner_guid = {$_SESSION['id']}))", "row_to_elggmetadata");
+ $result = get_data("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid=$entity_guid and m.name_id='$meta_name' and (m.access_id in {$access} or (m.access_id = 0 and m.owner_guid = {$_SESSION['id']}))", "row_to_elggmetadata");
+ if (!$result)
+ return false;
+
+ if (count($result) == 1)
+ return $result[0]->value;
+
+ return $result;
}
/**