/** *Counts the number of files uploaded by department */ public function fileCountDept() { $this->db->select('id,department,COUNT(*) as cnt'); $this->db->group_by('department'); $query = $this->db->get('documents'); if ($query->num_rows() > 0) { $dept = array(); foreach ($query->result() as $row) { $fileObj = new Document_Model($row->id); $department = $fileObj->getDepartmentName(); $dept[] = array('department' => $department, 'count' => $row->cnt); } echo json_encode($dept); } else { $msg = array('status' => 'error', 'msg' => 'There were no files to gather data on.'); echo json_encode($msg); exit; } }