Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 90 characters in body
Source Link
Cerad
  • 49k
  • 9
  • 92
  • 94

Something like:

$qb = $entityManager->createQueryBuilder(); $qb->select('count(account.id)'); $qb->from('ZaysoCoreBundle:Account','account'); $count = $qb->getQuery()->getSingleScalarResult(); 

Some folks feel that expressions are somehow better than just using straight DQL. One even went so far as to edit a four year old answer. I rolled his edit back. Go figure.

Something like:

$qb = $entityManager->createQueryBuilder(); $qb->select('count(account.id)'); $qb->from('ZaysoCoreBundle:Account','account'); $count = $qb->getQuery()->getSingleScalarResult(); 

Some folks feel that expressions are somehow better than just using straight DQL.

Something like:

$qb = $entityManager->createQueryBuilder(); $qb->select('count(account.id)'); $qb->from('ZaysoCoreBundle:Account','account'); $count = $qb->getQuery()->getSingleScalarResult(); 

Some folks feel that expressions are somehow better than just using straight DQL. One even went so far as to edit a four year old answer. I rolled his edit back. Go figure.

deleted 101 characters in body
Source Link
yivi
  • 48.2k
  • 18
  • 133
  • 158

Something like:

$qb = $entityManager->createQueryBuilder(); $qb->select('count(account.id)'); $qb->from('ZaysoCoreBundle:Account','account'); $count = $qb->getQuery()->getSingleScalarResult(); 

EDIT

Some folks feel that expressions are somehow better than just using straight DQL. One even went so far as to edit a four year old answer. I rolled his edit back. Go figure.

Something like:

$qb = $entityManager->createQueryBuilder(); $qb->select('count(account.id)'); $qb->from('ZaysoCoreBundle:Account','account'); $count = $qb->getQuery()->getSingleScalarResult(); 

EDIT

Some folks feel that expressions are somehow better than just using straight DQL. One even went so far as to edit a four year old answer. I rolled his edit back. Go figure.

Something like:

$qb = $entityManager->createQueryBuilder(); $qb->select('count(account.id)'); $qb->from('ZaysoCoreBundle:Account','account'); $count = $qb->getQuery()->getSingleScalarResult(); 

Some folks feel that expressions are somehow better than just using straight DQL.

added 172 characters in body
Source Link
Cerad
  • 49k
  • 9
  • 92
  • 94

Something like:

$qb = $entityManager->createQueryBuilder(); $qb->select($qb->expr()->count'count('accountaccount.id'id)'); $qb->from('ZaysoCoreBundle:Account','account'); $count = $qb->getQuery()->getSingleScalarResult(); 

EDIT

Some folks feel that expressions are somehow better than just using straight DQL. One even went so far as to edit a four year old answer. I rolled his edit back. Go figure.

Something like:

$qb = $entityManager->createQueryBuilder(); $qb->select($qb->expr()->count('account.id')); $qb->from('ZaysoCoreBundle:Account','account'); $count = $qb->getQuery()->getSingleScalarResult(); 

Something like:

$qb = $entityManager->createQueryBuilder(); $qb->select('count(account.id)'); $qb->from('ZaysoCoreBundle:Account','account'); $count = $qb->getQuery()->getSingleScalarResult(); 

EDIT

Some folks feel that expressions are somehow better than just using straight DQL. One even went so far as to edit a four year old answer. I rolled his edit back. Go figure.

added syntax highlighting, used expression helper instead of plain sql to count()
Source Link
Loading
Adjusted indents
Source Link
Chase
  • 9.4k
  • 5
  • 55
  • 80
Loading
Source Link
Cerad
  • 49k
  • 9
  • 92
  • 94
Loading