db->select()->from('feecategory'); if ($id != null) { $this->db->where('id', $id); } else { $this->db->order_by('id ' . $order); } $query = $this->db->get(); if ($id != null) { return $query->row_array(); } else { return $query->result_array(); } } public function getbyasc($id = null) { $this->db->select()->from('feecategory'); if ($id != null) { $this->db->where('id', $id); } else { $this->db->order_by('id'); } $query = $this->db->get(); if ($id != null) { return $query->row_array(); } else { return $query->result_array(); } } /** * This function will delete the record based on the id * @param $id */ public function remove($id) { $this->db->where('id', $id); $this->db->delete('feecategory'); } /** * This function will take the post data passed from the controller * If id is present, then it will do an update * else an insert. One function doing both add and edit. * @param $data */ public function add($data) { if (isset($data['id'])) { $this->db->where('id', $data['id']); $this->db->update('feecategory', $data); } else { $this->db->insert('feecategory', $data); return $this->db->insert_id(); } } }