symfony2:Sql语法错误

时间:2016-05-01 03:54:55

标签: php sql symfony

我想显示更多的论文列表那个记者,但我认为我的SQL查询语法有问题..这是我控制器中的整个功能:

`public function nonattribuéAction()
{
    $em=$this->getDoctrine()->getManager();
    $repository = $em->getRepository('administrationadministrationBundle:Papier');
    $repository = $em->getRepository('administrationadministrationBundle:CorrectionPap');
    $query = $em->createQuery('SELECT * FROM administaration\administrationBundle\Entity\Papier WHERE pNum IN (SELECT DISTINCT pNum FROM administaration\administrationBundle\Entity\CorrectionPapier GROUP BY pNum HAVING COUNT(rNum)=>0)');
    $papier = $query->getResult();
    return $this->render('administrationadministrationBundle:Default:papier.html.twig', array('papier' => $papier, 'name' => 'Papiers Non Attribués'));
}`

1 个答案:

答案 0 :(得分:0)

这就是答案:D

 public function nonattribuéAction()
{
    $em = $this->getDoctrine()->getEntityManager();
    $query = $em->createQuery('SELECT u FROM administrationadministrationBundle:Papier u WHERE u.pNum IN (SELECT DISTINCT v.pNum FROM administrationadministrationBundle:CorrectionPap v GROUP BY v.pNum HAVING COUNT(v.rNum)= 2)');
    $results = $query->getResult();
    return $this->render('administrationadministrationBundle:Default:papier.html.twig', array('papier' => $results, 'name' => 'Papiers Non Attribués'));
}