Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine 2 SUM() equivalent helper?

Strange, there is no SUM() equivalent in Doctrine2 helpers? There is max, min, count... am i blind?

// Example - $qb->expr()->avg('u.age')
public function avg($x); // Returns Expr\Func

// Example - $qb->expr()->max('u.age')
public function max($x); // Returns Expr\Func

// Example - $qb->expr()->min('u.age')
public function min($x); // Returns Expr\Func

// Example - $qb->expr()->abs('u.currentBalance')
public function abs($x); // Returns Expr\Func

// Example - $qb->expr()->sqrt('u.currentBalance')
public function sqrt($x); // Returns Expr\Func

// Example - $qb->expr()->count('u.firstname')
public function count($x); // Returns Expr\Func
like image 717
gremo Avatar asked Oct 10 '11 22:10

gremo


1 Answers

There does not appear to be a sum() helper. You can still use SUM in QueryBuilder; e.g:

$qb->add('select', 'SUM(u.id)')
   ->add('from', 'User u')
like image 124
Darragh Enright Avatar answered Sep 19 '22 23:09

Darragh Enright