如何重置关系中的默认范围?
询问:
$matches = MatchesStat::model()
->resetScope(true)
->with(array('best_player', 'bad_player'))
->findByAttributes(array(
'match_id' => $this->id,
'mode' => $this->mode
));
函数关系():
public function relations()
{
return array(
'best_player'=>array(self::BELONGS_TO, 'Players', '', 'on' => 't.best_pl = best_player.pl_id AND t.mode = best_player.mode', 'scopes' => array( 'resetScope' )),
'bad_player'=>array(self::BELONGS_TO, 'Players', '', 'on' => 't.bad_pl = bad_player.pl_id AND t.mode = bad_player.mode', 'scopes' => array( 'resetScope' ))
);
}
玩家,默认范围:
public function defaultScope()
{
return array(
'condition' => $this->getTableAlias(false, false) . '.mode = "main"',
);
}
如您所见,我在关系中使用 'scopes' => array( 'resetScope' )。但: