当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Doctrine countDistinct alias

问题描述:

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')
分享给朋友:
您可能感兴趣的文章:
随机阅读: