Symfony 2 create query

Asked

Viewed 66 times

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 mistake:

Error: Invalid PathExpression. Must be a StateFieldPathExpression

2 answers

0

The problem is the ->execute(). To run the Query you need to use the 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();

0

Trade your DQL for:

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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.