这是我的代码:
$hash = 0;
foreach ($this->championship->getRounds() as $round) {
$ranking = $this->getRanking($round);
echo "OLD_HASH: $hash, NEW_HASH: " . $ranking->getHash();
if ($hash != $ranking->getHash()) {
$ranking->fullUpdate();
}
$hash = $ranking->getHash();
echo "SAVE_NEW: $hash";
$matches = $this->getMatches($round);
$matches ->fullUpdate();
}
如果“Rounds”数组中有3个对象,则相应的“哈希”值为:1,2和3。
这就是我的期望:
OLD_HASH:0,NEW_HASH:1
SAVE_NEW:1
OLD_HASH:1,NEW_HASH:2
SAVE_NEW:2
OLD_HASH:2,NEW_HASH:3
SAVE_NEW:3
相反,这才是真正的结果:
OLD_HASH:0,NEW_HASH:1
SAVE_NEW:1
OLD_HASH:0,NEW_HASH:2
SAVE_NEW:2
OLD_HASH:0,NEW_HASH:3
SAVE_NEW:3
为什么?!?