0

My question heavily depends on this: Doctrine: Query only where relationship doesn't exist?

I wonder how the very same thing can be accomplished using Doctrine2. I am especially interested in good practices. Do I have to use the QueryBuilder or is it possible to use a findBy on a repository?

Community
  • 1
  • 1
CharlyDelta
  • 938
  • 11
  • 31

1 Answers1

0

Eventually I used QueryBuilder like this (example from the question linked above):

// $entitiyManager: Doctrine EntityManager instance
$qb = $entityManager->createQueryBuilder();
$x = $qb->expr();

$qb->select('article')
    ->from('Article', 'article')
    ->leftJoin('article.category', 'category')
    ->where($x->isNotNull('category.id');
CharlyDelta
  • 938
  • 11
  • 31