mongodb - Symfony2 and ODM flushing -
in project i'm using document "question" references (many document "category") after setting category of question , flushing nothing changes in database there code
$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();
and there no changes in database, 1 can please ? , here mapping in question's document :
/** *@mongodb\referencemany(targetdocument="category") */ protected $category
depending on changetrackingpolicy might need persist question before flushing.
$dm->persist($question); $dm->flush();
by persisting entity make sure changes in entity registered in unitofwork. flush send these actions database.
persist not directly cause query database since might want persist lot of entities. therefore actions 'buffered' until flush called on document manager.
Comments
Post a Comment