【问题标题】:How to use @SqlResultSetMapping in Symfony2, doctrine 2?如何在 Symfony2,学说 2 中使用 @SqlResultSetMapping?
【发布时间】:2016-11-17 18:52:39
【问题描述】:

有一个关于@SqlResultSetMapping的例子 http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/native-sql.html

我不明白我应该在哪里以及如何使用它?在控制器动作中?在某些自定义类或特征中?

【问题讨论】:

    标签: symfony doctrine-orm sqlresultsetmapping


    【解决方案1】:

    您可以在可以访问定义它的实体的存储库类的任何地方使用它,即来自控制器:

    $em = $this->getDoctrine()->getManager();
    $repo = $em->getRepository("SomeCertainBundle:YourEntity");
    $results = $repo->createNativeNamedQuery("name-of-the-query")->execute();
    

    【讨论】:

      猜你喜欢
      • 2012-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-15
      • 1970-01-01
      • 2014-02-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多