usmanhalalit / pixie

Database query builder for PHP, framework agnostic, lightweight and expressive.
MIT License
672 stars 180 forks source link

issue in count() #202

Open mromid opened 5 years ago

mromid commented 5 years ago

when i run this query every thing is ok : $stmt = $db->table('call_history') ->select('id') ->where('caller_id', $operator_id) ->groupBy('user_id') ->get(); // result is 5 record but
run this query : $stmt = $db->table('call_history') ->select('id') ->where('caller_id', $operator_id) ->groupBy('user_id') ->count(); // result is number 30 (common record not grouped)

groupby not true work !

when i remove groupBy from my query every thing is ok

eL-Prova commented 5 years ago

@mromid Its hard to read what you are trying to say. What do you expect? The 5 or the 30 records? Have you tried to see the extracted sql? In this case what is your raw query output...

catchem99 commented 5 years ago

I think I got what he means, Steps to reproduce: Import this really simple table OR make one like: purchase_id,purchase_code 1,abc 2,def

Then use QB::table('TABLENAME')->groupBy('purchase_code')->count(); //This will return 1 while if you use a standard query SELECT * FROM TABLENAME GROUP BY purchase_code //It should return 2

EDIT: tested on MySQL

mtarlac commented 5 years ago

Same problem like #180