count(*)

webcrea 11 May, 2015
Hello,

Always in the honors manager, I would want to count how many honors has each user in users list

Main Model is users

new Model is honor_map with user_id and honor_id field
Relation : HasMany
Foreign Key : id
Fields:count(*)
Group : user_id

I have in debug
[4] => SELECT count(*) AS `*` FROM `skf0d_honor_map` AS `Honor_map` WHERE `Honor_map`.`id` IN ('491', '12680', '12696', '1003587', '1', '63', '444', '991', '992', '998', '1009', '1050', '1051', '1097', '2684', '5846', '8828', '12117', '14744', '15575', '15605', '19823', '20453', '21229', '22721', '1000103', '1000234', '1000480', '1000593', '1000651') GROUP BY `Honor_map`.`user_id`
)

How can I do to have only the same as a counter of a grouped fields ?
SELECT count(*) AS c FROM `skf0d_honor_map` WHERE `Honor_map`.`id` GROUP BY `Honor_map`.`user_id`

And in the front list setting I add in Columns list Honor_map.*:Awards
but nothing appears

regards
chris
GreyHead 14 May, 2015
Hi Chris,

Looking at this line the WHERE clause is broken
SELECT count(*) AS c FROM `skf0d_honor_map` WHERE `Honor_map`.`id` GROUP BY `Honor_map`.`user_id`
Perhaps adding a Condition that is always true will work? Like
return array( '1' => '1');

Bob
webcrea 18 May, 2015
Hello Bob and thanks,
with 25000 users I had to change my strategy to count honors
Chris
This topic is locked and no more replies can be posted.