Php Doctrine2 insert仅在某些记录上以静默方式失败

Php Doctrine2 insert仅在某些记录上以静默方式失败,php,mysql,symfony,doctrine-orm,Php,Mysql,Symfony,Doctrine Orm,我有以下代码,有时会导致无声故障: public function updateCoreGameTableIfNecessary($coreEm) { $game = $this->getCoreGameRecord($coreEm); if (!$game) { $game = new Game(); $game->setHomeSchool($this->getHomeSchool()->getCoreScho

我有以下代码,有时会导致无声故障:

public function updateCoreGameTableIfNecessary($coreEm)
{   
    $game = $this->getCoreGameRecord($coreEm);

    if (!$game) {

        $game = new Game();
        $game->setHomeSchool($this->getHomeSchool()->getCoreSchool($coreEm));
        $game->setDatetime($this->getDatetime()->format('Y-m-d H:i:s'));
        $game->setDate($this->getDatetime()->getTimestamp());
        $game->setTime($this->getDatetime()->format('H:i:s'));
        $game->setSport($coreEm->getRepository('VNNCoreBundle:Sport')->findOneByName($this->getSport()->getName()));
        $game->setSeason($coreEm->getRepository('VNNCoreBundle:Season')->findCurrent());
        $game->setEventType(strtolower($this->getEventType()->getName()));
        $game->setMeetName($this->getMeetName());
        $game->setRemoteUnique(md5(rand(0, 100000)));
        $game->setNotes($this->getRecap());
        $game->setHomeConfId(0); // This field is no longer used, so value doesn't matter.
        $game->setAwayConfId(0); // This field is no longer used, so value doesn't matter.
        $game->setConfStatus(''); // This field is going away as well.
    }   

    if ($this->getEventType()->getName() == 'Game') {
        $game->setHomeScore($this->getHomeScore());
        $game->setAwayScore($this->getAwayScore());
        $game->setAwaySchool($this->getAwaySchool()->getCoreSchool($coreEm));
    } else {
        $game->setPlace($this->getPlace());
        $game->setPoints($this->getHomeScore());
    }   

    $game->setOwnerId($this->getUser()->getSchool()->getCoreSchool($coreEm)->getId());
    $coreEm->persist($game);
    $coreEm->flush();

    return $game->getId();
}   
它总是以已经保存的$this开头。对于$this的某些实例,即数据库中的某些记录,$game将不会保存。我不会犯这样的错误。它只会默默地失败


对调试有什么建议吗?我想我会尝试找出这些特定记录的不同之处,但似乎插入操作永远不会因为任何原因而自动失败。

是否设置了错误报告以报告所有错误?是否记录了这些错误,或者是否设置了显示错误以在屏幕上显示这些错误?是。我已收到所有其他数据库错误的通知。这个失败的插入似乎没有抛出任何错误。如下语句:$game->setSport$coreEm->getRepository'vnncorundle:Sport'->findOneByName$This->getSport->getName;它们很危险。如果在Sport存储库中未找到任何记录,则您正在对非对象调用方法getName。导致致命错误。我希望现在就发生致命错误。我得到的是没有错误。可能有帮助:根据MySQL查询日志,我的代码根本没有执行任何查询。我不知道为什么,但我想这是另一个难题。