How do I select count distinct of a column and actually get the count as a scalar integer?
No matter what I try, I get the result in this awful nested array format:
array:1 [▼
0 => array:1 [▼
1 => "1"
]
]
Does anyone have an example of how to reliably just get an integer count from this?
The above result is from using code suggested by How to use countDistinct in Doctrine query builder (Symfony)
Unfortunately, the answer there doesn't explain how to get the result in a more usable format.
I'm not even sure how to reliably get the number out of these nested arrays. It seems like I'd have to perform several is_array()
and array length checks, and it's not clear why the key in the nested array is 1
or if it will always be that.
source https://stackoverflow.com/questions/69759338/doctrine-query-builder-dql-how-to-get-distinct-count-out-of-countdistinct
Comments
Post a Comment