drfu29983
2012-08-10 12:08
浏览 43
已采纳

Doctrine countDistinct别名

How i can set an alias for a countDistinct expr using Doctrine queryBuilder?

$qb->addSelect($qb->expr()->countDistinct('_charges.id'));

图片转代码服务由CSDN问答提供 功能建议

如何使用Doctrine queryBuilder为countDistinct expr设置别名?

  $ qb-> addSelect($ qb-> expr() - > countDistinct('_ charges.id')); 
   
 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douju6651 2012-08-10 12:57
    已采纳

    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')
    
    点赞 打赏 评论

相关推荐 更多相似问题