Skip to content

Commit

Permalink
Merge pull request #312 from felixgilles/bugfix_update_original_relat…
Browse files Browse the repository at this point in the history
…ions

Query hydrate: update_original_relation only for relations concerned
  • Loading branch information
WanWizard committed Jan 27, 2014
2 parents f462c55 + d79236a commit c025511
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion classes/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1115,13 +1115,15 @@ public function hydrate(&$row, $models, &$result, $model = null, $select = null,

// start fetching relationships
$rel_objs = $obj->_relate();
$relations_updated = array();
foreach ($models as $m)
{
// when the expected model is empty, there's nothing to be done
if (empty($m['model']))
{
continue;
}
$relations_updated[] = $m['rel_name'];

// when not yet set, create the relation result var with null or array
if ( ! array_key_exists($m['rel_name'], $rel_objs))
Expand All @@ -1142,7 +1144,7 @@ public function hydrate(&$row, $models, &$result, $model = null, $select = null,

// attach the retrieved relations to the object and update its original DB values
$obj->_relate($rel_objs);
$obj->_update_original_relations();
$obj->_update_original_relations($relations_updated);

return $obj;
}
Expand Down

0 comments on commit c025511

Please sign in to comment.