Hi, If i have two models, for example Users and Orders and i run this code:
$order = Orders::findFirstById(1);
echo $order->user->name;
$order->update();
Phalcon is firing beforeUpdate() in Users model. How to prevent this? How to unbind/unlink relations before update? The only thing I can do now is to reload the record before update.
$order = Orders::findFirstById(1);
echo $order->user->name;
$order = Orders::findFirstById(1);
$order->update();
This will not fire beforeUpdate() in Users model. I tried to add 'foreignKey' => array('action' => \Phalcon\Mvc\Model\Relation::NO_ACTION) in Orders model but it doesnt work.
Relation in Orders:
$this->belongsTo('user_id', '\Model\Users\Users', 'id', array(
'alias' => 'user',
'reusable' => true,
'foreignKey' => array('action' => \Phalcon\Mvc\Model\Relation::NO_ACTION)
));
The problem is that i'm changing user modification time in beforeUpdate() in Users model, so when i update Orders without changing anything in Users (only getting name for example) Phalcon is updating modification time in Users.