aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-06 14:21:44 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-03-06 14:21:44 +0000
commitf0cc1dbedd660c3d1e3014fe5673cfb2d77622ae (patch)
tree8ec26ede0e296ae1fbb5526a824ba20b9cdfc1e8 /engine
parent674205a2651af6f7e611dc001f6efc349580df55 (diff)
downloadelgg-f0cc1dbedd660c3d1e3014fe5673cfb2d77622ae.tar.gz
elgg-f0cc1dbedd660c3d1e3014fe5673cfb2d77622ae.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Casting takes advantage of constructor git-svn-id: https://code.elgg.org/elgg/trunk@99 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/objects.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/engine/lib/objects.php b/engine/lib/objects.php
index 62039ff38..f939b0ce5 100644
--- a/engine/lib/objects.php
+++ b/engine/lib/objects.php
@@ -21,10 +21,8 @@
function row_to_elggobject($row) {
if (empty($row))
return $row;
- $object = new ElggObject();
- foreach(get_object_vars($row) as $property => $value)
- $object->$property = $value;
- return $object;
+
+ return new ElggObject($row);
}
/**
@@ -367,8 +365,13 @@
$this->attributes = array();
- if (!empty($id)) {
- if ($object = get_object($id)) {
+ if (!empty($id)) {
+ if ($id instanceof stdClass)
+ $object = $id; // Create from db row
+ else
+ $object = get_object($id);
+
+ if ($object) {
$objarray = (array) $object;
foreach($objarray as $key => $value) {
$this->attributes[$key] = $value;