function CountCommonFollowing() { $following2_dao = new Following2_dao(); $following2 = $following2_dao->getAll(); $following_dao = new Following_dao(); $following_dao->resetCommonFollowing(); foreach ($following2 as $fol2) { $count = 0; $id2 = $fol2->id2; $following = $following_dao->getAll(); foreach ($following as $fol) { $id = $fol->id; if ($id2 == $id) { $follow = $following_dao->getById($fol2->id); $count = $follow->common_friends_count + 1; //echo $count; $following_dao->addCommonFollowing($fol2->id, $count); } } //echo "<br/>"; //echo $count; } }