1

I need help with translation MySQL to Doctrine query.

There is a query what I want to translate:

SELECT izo_order.id 
FROM izo_order 
WHERE izo_order.id 
NOT IN (SELECT izo_installation.order_id 
        FROM izo_installation 
        WHERE izo_installation.order_id=izo_order.id)
        AND izo_order.client_id = 4

I did something like that, but it seems not to work:

$qb = $this->_em->createQuery('SELECT o
FROM AppBundle:Order o
WHERE o.id
NOT IN (SELECT i.order
        FROM AppBundle:Installation i
        WHERE i.order=o.id)
        AND o.clientBelongsTo = :client_id')->setParameter('client_id', $client_id);

        return $qb->getResult();
verdun3r
  • 71
  • 2
  • 9

1 Answers1

0

You query looks good, but Your where clause in the subquery should cause the error. Try it without that:

$qb = $this->_em->createQuery('SELECT o
FROM AppBundle:Order o
WHERE o.id
NOT IN (SELECT IDENTITY(i.order)
    FROM AppBundle:Installation i)
    AND o.clientBelongsTo = :client_id')->setParameter('client_id', $client_id);
$qb->getResult();

If you still have the error, You should post the error.

CiTNOH
  • 186
  • 1
  • 8