Skip to content

Instantly share code, notes, and snippets.

@jesusOmar
Created February 8, 2015 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesusOmar/5573b560cc533ae5c47b to your computer and use it in GitHub Desktop.
Save jesusOmar/5573b560cc533ae5c47b to your computer and use it in GitHub Desktop.
Doctrine Query Help
<?php
$qb2 = $this->createQueryBuilder('a2')
->select('a2')
->innerJoin('a2.registrations', 'appointment_registrations')
->where('a2.id = a1.id') // This does not work :(
;
$qb = $this->createQueryBuilder('a1');
$qb->where($qb->expr()->not($qb->expr()->exists($qb2->getDql())));
SELECT a1.*
FROM appointments a1 WHERE
NOT
( EXISTS
(
SELECT a2.* FROM appointments a2
INNER JOIN appointment_registrations r on r.appointmentId = a2.id
WHERE a2.id = a1.id
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment