Symfony2 & Doctrine: Create custom SQL-Query

后端 未结 2 737
野趣味
野趣味 2020-12-05 10:14

How can I create a custom SQL query in Symfony2 using Doctrine? Or without Doctrine, I don\'t care.

Doesn\'t work like this:

    $em = $this->getD         


        
2条回答
  •  情话喂你
    2020-12-05 10:49

    You can execute this code it works :

    $em = $this->getDoctrine()->getEntityManager();
    $result= $em->createQuery($sql)->getResult();
    

提交回复
热议问题