如何阻止教义 2 在 Symfony 2 中缓存结果?
2022-08-30 13:54:22
我希望能够检索实体的现有版本,以便将其与最新版本进行比较。例如,编辑一个文件,我想知道值自进入数据库以来是否发生了变化。
$entityManager = $this->get('doctrine')->getEntityManager();
$postManager = $this->get('synth_knowledge_share.manager');
$repository = $entityManager->getRepository('KnowledgeShareBundle:Post');
$post = $repository->findOneById(1);
var_dump($post->getTitle()); // This would output "My Title"
$post->setTitle("Unpersisted new title");
$existingPost = $repository->findOneById(1); // Retrieve the old entity
var_dump($existingPost->getTitle()); // This would output "Unpersisted new title" instead of the expected "My Title"
有谁知道我该如何绕过这个缓存?