php - codeigniter, how to get multiple query and counted it from model

i'm new on codeigniter. and I'm trying to get my model to return two queries, one for the data itself which is a few notes from the table, and the calculation field. and returns the output of the form (very good, good, and bad). with poll where he relates to officer_name. the problem is when i use count(*) from three different query the result is only null.

this is query from my model.

                ->select('count(a.poll) as verygood')
                ->where('b.officer_name', $officer['officer_name'])
                ->select('count(a.poll) as good')
                ->where('b.officer_name', $officer['officer_name'])
                ->select('count(a.poll) as bad')
                ->where('b.officer_name', $officer['officer_name'])
$this->db->from('tbl_poll as a');
$this->db->join('tbl_officer as b', 'a.id_officer = b.id_officer');
$this->db->join('tbl_service as c', 'b.id_service = c.id_service');
return $this->db->get()->result_array();

This is output i wanted:

Officer_name | Service |        Polls          |
             |         | Verygood | Good | Bad |
Bella        | Payments|    3     |  2   |  1  |
Christy      |   CS    |    5     |  3   |  0  |
ETC.         |   etc   |    3     |  3   |  3  |

Can somebody help me and how to do this, or a fix for my current code?

Thank you in advance!

sorry my english was so bad

0 Comment



Captcha image