fluentpdo icon indicating copy to clipboard operation
fluentpdo copied to clipboard

Wrong count() for query with offset

Open pandatamara opened this issue 6 years ago • 3 comments

Hi! If i try get count() for my query with offset, i get wrong result 0. i can fix bug:

$tx->select('COUNT(*)', true)->offset(0)->fetchColumn()

If this solution fine - can you add this to lib, plz?

pandatamara avatar Sep 09 '19 19:09 pandatamara

This is probably related to #199 and should have been fixed with #200 but looks like it isn't. If you have this problem with a group by query, you're fix will not work. See #199 for details.

hapm avatar Sep 09 '19 20:09 hapm

@pandatamara can you add the full context of your issue here? The query you're using offset with that's returning 0 please.

@hapm From what I remember of attempts to fix this issue in 2.0, there were major problems with having the query parts stored as strings, and would've required a complete overhaul to fully resolve, so we had to put it on hold.

cbornhoft avatar Sep 10 '19 14:09 cbornhoft

@cbornhoft then I guess a fast fix would be to document that count() doesn't work properly on grouped queries.

hapm avatar Sep 10 '19 14:09 hapm