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.
$this->db->select('a.id_poll')
->select('a.poll')
->select('a.date')
->select('a.id_officer')
->select('b.officer_name')
->select('c.id_service')
->select('c.service_name')
->select('count(a.poll) as verygood')
->where('b.officer_name', $officer['officer_name'])
->where('a.poll','verygood')
->select('count(a.poll) as good')
->where('b.officer_name', $officer['officer_name'])
->where('a.poll','good');
->select('count(a.poll) as bad')
->where('b.officer_name', $officer['officer_name'])
->where('a.poll','bad');
$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
NO COMMENTS