Hi all, today I've found an issue with model updating if it has relationship and if I use alias property to get the related data before trying to update the field.

The following exemple doesn't work:

$x = Visibility::findFirst(238);
if ($x->resource->getId() != 33) {
  $x->setIdResource(33);
  $x->save();
}

If I re-query the object after using the relationship it works again:

$x = Visibility::findFirst(238);
if ($x->resource->getId() != 33) {
  $x = Visibility::findFirst(238); // re-query
  $x->setIdResource(33);
  $x->save();
}

Any advice?

Seems that I'm not alone: http://stackoverflow.com/questions/18346569/phalconphp-framework-how-to-update-a-model-object-and-the-related-object