envms / fluentpdo

A PHP SQL query builder using PDO
http://envms.github.io/fluentpdo/
926 stars 189 forks source link

Wrong count() for query with offset #300

Open pandatamara opened 5 years ago

pandatamara commented 5 years ago

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?

hapm commented 5 years ago

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.

cbornhoft commented 5 years ago

@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.

hapm commented 5 years ago

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