‘where not in’ query with doctrine query builder

You need to use query builder expressions, and this means you need access to the query builder object. Also, the code is easier to write if you generate the subselect list ahead of time: $qb = $em->createQueryBuilder(); $nots = $qb->select(‘arl’) ->from(‘$MineMyBundle:MineAssetRequestLine’, ‘arl’) ->where($qb->expr()->eq(‘arl.asset_id’,1)) ->getQuery() ->getResult(); $linked = $qb->select(‘rl’) ->from(‘MineMyBundle:MineRequestLine’, ‘rl’) ->where($qb->expr()->notIn(‘rl.request_id’, $nots)) ->getQuery() ->getResult();

Symfony 2 + Doctrine 2 + PHPUnit 3.5: Serialization of closure exception

Not technically related to your issue. However, I had a really hard time trying to solve the “Serialization of ‘Closure’ is not allowed” issue while using PHPUnit, and this question is the top Google result. The problem comes from the fact that PHPUnit serializes all the $GLOBALS in the system to essential back them up … Read more

How to get a Collection in Doctrine2’s query results

The getResult() always returns an array. If you want a collection, you must pass the array that is returned by getResult() to Doctrine’s ArrayCollection e.g. use Doctrine\Common\Collections\ArrayCollection; $result = $this ->getEntityManager() ->createQueryBuilder() ->select(‘p’) ->from(‘…\Player’, ‘p’) ->getQuery() ->getResult() ; $players = new ArrayCollection($result);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)