I have a table to manage the votes for a list of videos and I need to get how much votes the single entry have.
This is my table:
id | user_id | entry_id | vote
And this an example of entries:
1 | 1 | 729 | 3
2 | 2 | 729 | 4
3 | 3 | 729 | 4
4 | 4 | 729 | 1
5 | 5 | 729 | 4
I need to get how much users vote 1, 3 and 4 and the total users that voted that entry.
In this case I shoud get:
Users that voted 1: 1
Users that voted 3: 1
Users that voted 4: 3
Total user: 5
In this case I can create the percent with php.
This is what I did with active records:
$this->db->select('COUNT(*) as tot_users, vote', FALSE);
$this->db->from('voti_video');
$this->db->where('entry_id', $id_entry);
$this->db->group_by('vote');
With this code I get exactly what users voted and how many of them voted.
How can I now get the total numbers of users without make a new query?
Is it possibile?