小编Ell*_*oad的帖子

如何阻止Doctrine 2在Symfony 2中缓存结果?

我希望能够检索实体的现有版本,以便将其与最新版本进行比较.例如,编辑文件,我想知道自从进入数据库以来该值是否已更改.

    $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"
Run Code Online (Sandbox Code Playgroud)

有谁知道如何绕过这个缓存?

php caching symfony doctrine-orm

27
推荐指数
2
解决办法
1万
查看次数

在Symfony2中,如何在Controller中将链接重定向到带有锚标记/哈希的URL

我在控制器中,我想重定向回URL,比如/ home/news/example#comment1423

如何将哈希值添加到返回参数中?

return $this->redirect(
    $this->generateUrl("news_view", array("permalink" => "example"))
);
Run Code Online (Sandbox Code Playgroud)

routing symfony

18
推荐指数
2
解决办法
3万
查看次数

标签 统计

symfony ×2

caching ×1

doctrine-orm ×1

php ×1

routing ×1