Hi,
I have a model which references another model in a 'belongsTo' relationship:
class Property extends \Phalcon\Mvc\Model
{ ....
public function initialize()
{...
$this->belongsTo('park_id', 'Park', 'id', array('alias' => 'Park'));
}
}
The park/park_id can be null. In the scenario where property->park_id is set, and I want to change it to null, the following code works:
$property = Property::findFirstByid($id);
$property->park_id = null;
$property->save();
$property->park is null
However, when I insert, for example, an echo statement, property->park retains the old value
$property = Property::findFirstByid($id);
echo $property->park->name;
$property->park_id = null;
$property->save();
$property->park has old value.
Can someone explain to me why this is? Is there a better way to unset a related model?
Thanks in advance!