Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个“简单”的问题,其答案似乎不在官方 DQL 文档中。给定一个使用 Doctrine2 构建的应用程序,假设有一个布尔列(假设实体Foo为B),如何计算行数以使 B 中的值为真(或假)?
PS:如果可能有帮助,我使用 MySql
如果您想计算“真”值的数量:
'SELECT COUNT(f.B) as numtrue FROM Foo f WHERE f.B = TRUE'
要获得“假”值的出现次数:
'SELECT COUNT(f.B) as numfalse FROM Foo f WHERE f.B = FALSE'