let's say I have model A with relation to B.
When I write:
$a = A::model()->findByPK(1);
$a->B->doSomething();
and now B may by changed (by other user for instance). When I write:
$a->B->doSomething();
it uses old values of B. What I should do to force to refresh value of B before doSomething().
Yii provides a refresh() method I think thats what your looking for?
http://www.yiiframework.com/doc/api/CActiveRecord#refresh-detail
You can get a refreshed 'B' value by saying:
$a->getRelated('B',true)->doSomething();
The 2nd param "true" asks that yii reload the relation from the database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With