我有一段遍历团队记录的所有相关概要记录(HAS_MANY)的代码。
它看起来是这样的:
$team = Team::model()->findByPk(1);
$score = 0;
foreach ($team->profiles as $profile) {
$score += $profile->getScore();
}现在我需要保留$team变量,但是由于循环的原因,所有的配置文件都将保存在profiles属性中,并且会占用大量内存。
有没有安全清理的方法?我考虑过将profiles设置为null,但它显然仍然为空(并且我不知道稍后是否需要另一段代码来访问profiles )
https://stackoverflow.com/questions/41300487
复制相似问题