How i can set an alias for a countDistinct expr using Doctrine queryBuilder?
$qb->addSelect($qb->expr()->countDistinct('_charges.id'));
How i can set an alias for a countDistinct expr using Doctrine queryBuilder?
$qb->addSelect($qb->expr()->countDistinct('_charges.id'));
You can't. Here's what the countDistinct function returns:
return 'COUNT(DISTINCT ' . implode(', ', func_get_args()) . ')';
You could however directly call the select function like this:
select('COUNT(DISTINCT _charges.id) AS charges')