mysql - 如何使用 Symfony 插件 DbFinderPlugin 制定查询以按列分组进行计数?

标签 mysql plugins symfony1 count

我不知道如何使用 DbFinderPlugin 1.2.2 与 Symfony 和 Propel 编写以下查询:

SELECT species, COUNT(*) FROM Bird GROUP BY species;

Here is the DbFinderPlugin page

我对这个插件相当陌生,到目前为止我确实很喜欢它,但这个查询到目前为止一直困扰着我。

最佳答案

我不是 DBFinder 的专家,但看起来以下应该可行

$result = DbFinder::from('Bird')->
  groupBy('species')-> 
  select(array('species', 'count(*) cnt'))->
  find();

编辑更改代码

关于mysql - 如何使用 Symfony 插件 DbFinderPlugin 制定查询以按列分组进行计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/930902/

相关文章:

php - 只显示mysql中IN子句中指定的id

javascript - 如何开发网络浏览器插件而不是 NPAPI(大多数浏览器已弃用)?

java - craftbukkit.v1_15_R1.entity.CraftPlayer 无法转换

email - 交响乐 1.4 : How to send i18n mail to a user who is not the current user (different culture)

php - 内连接中的 Doctrine 子查询

php - bind_result 和 fetch 返回 null

MySQL 空间扩展 : Getting records that fall with in a certain area

php - Doctrine 无关系加入

mysql - 我应该在 SQL 过程中使用游标吗?

c# - 从 .net DLL 导出 native C 函数?