donglinyi4313 2017-06-12 14:01
浏览 67
已采纳

symfony从实体中提取数据

Hello i have a problem i would like to retrieve data from my entity in Symfony here is the code:

  public function indexAction(Request $request , $id)
    {

        $getDoctrine = $this->getDoctrine()->getManager();

        $email = $getDoctrine->getRepository('desplayBundle:people')->find($id);
        dump($email);

        return $this->render('emailBundle:Default:index.html.twig', array());
    }

I would like to retrieve the data inside my controller and not in twig.

  • 写回答

2条回答 默认 最新

  • duanliusong6395 2017-06-12 14:12
    关注

    You want to get email from user ?

    public function indexAction(Request $request , $id)
    {
    
        $getDoctrine = $this->getDoctrine()->getManager();
    
        $user = $getDoctrine->getRepository('desplayBundle:people')->find($id);
        $email = $user->getEmail();
    
        return $this->render('emailBundle:Default:index.html.twig', array());
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?