Symfony 2 create query

1
createQuery("select p.name from blogBundle:Person p
         where p.id not in(select c.person from blogBundle:Category c)")->execute();

And I'm getting this error:

Error: Invalid PathExpression. Must be a StateFieldPathExpression
    
asked by anonymous 02.03.2015 / 17:50

2 answers

0

Change your DQL by:

SELECT p
FROM blogBundle:Person p
WHERE p.id NOT IN(
    SELECT IDENTITY(p.id)
    FROM blogBundle:Category c
    JOIN c.person p)

Note the IDENTITY .

    
03.03.2015 / 00:33
0

The problem is ->execute() . To run Query you need to use getResult() .

The correct form is:

$this->getEntityManager()->createQuery("select p.name from blogBundle:Person p
         where p.id not in(select c.person from blogBundle:Category c)")->getResult();
    
16.02.2017 / 19:31