0

I have set relations: 'teamDrivers' => array(self::HAS_MANY, 'TeamDriver', 'team_id') in my Team model

So if I want I can: print_r($this->teamDrivers); in my Team. Just for demonstration.

Now the problem is that this kind of code produces a list of items that have already been removed form database! Via CActiveDataProvider with CDbCriteria those items are not reached.

If I log out from my app and then log back in everything seems to be working.

So is there some cache that takes care of those relations or what is this mystery? And how do I clear that cache?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Gessle
  • 255
  • 1
  • 3
  • 10
  • Are you executing the `print_r($this->teamDrivers)` immediately after deleting the `teamDrivers`? – topher Jan 12 '13 at 10:29
  • I can wait few minutes and it still produces the same effect. – Gessle Jan 12 '13 at 10:49
  • Hmm, this is less likely to help due to the fact that a few minutes can pass with no change (I assume that also means a new page load),but have you tried `$this->refresh()` before you attempt the `print_r`? That should wipe out the short term cache in the model, although reloading a page would do the same. – Willem Renzema Jan 12 '13 at 13:50
  • Actually that was the problem. There was old model still used. – Gessle Jan 13 '13 at 09:38
  • @Gessle even when models are deleted through `CActiveRecord::delete()` the model instance still holds all the data it had before. This can be useful for undoing the delete action or doing some clean up after deletes. – topher Jan 13 '13 at 20:38

1 Answers1

0

In my case UserIdentity object had old information and team was got through it. Refreshing was the solutions.

Gessle
  • 255
  • 1
  • 3
  • 10