在我的项目中,我正在使用一个文档“问题”,它在设置问题的类别并刷新我的数据库中没有任何更改之后引用(许多到另一个文档“类别”)有我的代码
$dm = $this->getDocumentManager();
$question = $this->getDocumentManager()->getRepository('ATS\QuizzBundle\Document\Question')->findOneByQuestion("a?");
$category = $this->getDocumentManager()->getRepository('ATS\QuizzBundle\Document\Category')->findOneByLabel("Logic");
$question->addCategory($category);
$dm->flush();
我的数据库没有任何变化,有人可以帮忙吗?这是我在问题文档中的映射:
/**
*@MongoDB\ReferenceMany(targetDocument="Category")
*/
protected $category