From 2569f2fc7fd8ca16bb05368add59bc3a257ef526 Mon Sep 17 00:00:00 2001 From: siddhuphp Date: Thu, 13 Feb 2020 18:11:01 +0530 Subject: [PATCH] general model file updated --- .../application/models/General_model.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/CodeIgniter_HMVC_REST_API/application/models/General_model.php b/CodeIgniter_HMVC_REST_API/application/models/General_model.php index 17eb3d2..79daa28 100644 --- a/CodeIgniter_HMVC_REST_API/application/models/General_model.php +++ b/CodeIgniter_HMVC_REST_API/application/models/General_model.php @@ -200,7 +200,8 @@ public function get_all_from_join($data) "order_by" => [ ["column" => "A.Name", "type" => 'ASC'], ["column" => "A.id", "type" => 'DESC'] - ] + ], + "group_by" => ['column1','column2','column3'] ]; */ @@ -278,6 +279,11 @@ public function get_all_from_join($data) } + //Group by + if(isset($data['group_by']) && !empty($data['group_by']) && is_array($data['group_by'])) + { + $this->db->group_by($data['group_by']); + } $q = $this->db->get(); @@ -315,7 +321,8 @@ public function get_row_from_join($data) ["column" => "A.status", "value" => 'Active'] ], "limit" => ["start" => 1, "end" => 5], - "order_by" => ["column" => "A.Name", "Type" => 'ASC'], + "order_by" => ["column" => "A.Name", "Type" => 'ASC'], + "group_by" => ['column1','column2','column3'] ]; */ @@ -372,6 +379,13 @@ public function get_row_from_join($data) $this->db->order_by($data['order_by']['column'],$order_type); } + + + //Group by + if(isset($data['group_by']) && !empty($data['group_by']) && is_array($data['group_by'])) + { + $this->db->group_by($data['group_by']); + } $q = $this->db->get(); // echo $this->db->last_query(); exit;