From f4b099236c0d70c51fdb0c0d573883f342daaef8 Mon Sep 17 00:00:00 2001 From: icewing Date: Thu, 6 Mar 2008 16:05:20 +0000 Subject: Marcus Povey * Casting done git-svn-id: https://code.elgg.org/elgg/trunk@102 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/metadata.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'engine/lib/metadata.php') diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index a02ff1ad7..777d3b58e 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -102,6 +102,20 @@ } + /** + * Convert a database row to a new ElggMetadata + * + * @param stdClass $row + * @return stdClass or ElggMetadata + */ + function row_to_elggmetadata($row) + { + if (!($row instanceof stdClass)) + return $row; + + return new ElggMetadata($row); + } + /** * Detect the value_type for a given value. * Currently this is very crude. @@ -210,7 +224,7 @@ $id = (int)$id; $access = get_access_list(); - return get_data_row("SELECT * from {$CONFIG->dbprefix}metadata where id=$id and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"); + return row_to_elggmetadata(get_data_row("SELECT * from {$CONFIG->dbprefix}metadata where id=$id and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))")); } /** @@ -262,7 +276,7 @@ $query .= $where[$n]; } - return get_data($query); + return get_data($query, "row_to_elggmetadata"); } /** -- cgit v1.2.3