Skip to content

Instantly share code, notes, and snippets.

@rela589n
Created November 6, 2023 14:05
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 rela589n/10091d8810d5eeb6d97c50fcdda204dc to your computer and use it in GitHub Desktop.
Save rela589n/10091d8810d5eeb6d97c50fcdda204dc to your computer and use it in GitHub Desktop.
Doctrine select EXISTS query
public function hasEntities(): bool
{
$qb = $this->createYourQueryBuilder();
$qb->select((string)$qb->expr()->literal('1'))
->setMaxResults(1);
$result = $qb->getQuery()->getOneOrNullResult();
return null !== $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment