diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-06 16:05:20 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-06 16:05:20 +0000 |
commit | f4b099236c0d70c51fdb0c0d573883f342daaef8 (patch) | |
tree | cc92f208b99f0e9037ad2ff5abb39b31b63a51c7 /engine | |
parent | c707dea442574edaac1ea4789bef194ee16a4caf (diff) | |
download | elgg-f4b099236c0d70c51fdb0c0d573883f342daaef8.tar.gz elgg-f4b099236c0d70c51fdb0c0d573883f342daaef8.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Casting done
git-svn-id: https://code.elgg.org/elgg/trunk@102 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/annotations.php | 21 | ||||
-rw-r--r-- | engine/lib/metadata.php | 18 |
2 files changed, 34 insertions, 5 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index c249420f3..c02ad10fa 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -102,6 +102,21 @@ } /** + * Convert a database row to a new ElggAnnotation + * + * @param stdClass $row + * @return stdClass or ElggAnnotation + */ + function row_to_elggannotation($row) + { + if (!($row instanceof stdClass)) + return $row; + + return new ElggAnnotation($row); + } + + + /** * Get a specific annotation. * * @param int $annotation_id @@ -113,7 +128,7 @@ $annotation_id = (int) $annotation_id; $access = get_access_list(); - return get_data_row("select o.* from {$CONFIG->dbprefix}annotations where id=$annotation_id and (o.access_id in {$access} or (o.access_id = 0 and o.owner_id = {$_SESSION['id']}))"); + return row_to_elggannotation(get_data_row("select o.* from {$CONFIG->dbprefix}annotations where id=$annotation_id and (o.access_id in {$access} or (o.access_id = 0 and o.owner_id = {$_SESSION['id']}))")); } /** @@ -164,8 +179,8 @@ if ($n > 0) $query .= " and "; $query .= $where[$n]; } - error_log($query); - return get_data($query); + + return get_data($query, "row_to_elggannotation"); } /** 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 @@ -103,6 +103,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"); } /** |