Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding group_by #404

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion application/libraries/Grocery_CRUD.php
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,9 @@ protected function get_list()
if(!empty($this->order_by))
$this->basic_model->order_by($this->order_by[0],$this->order_by[1]);

if (!empty($this->group_by))
$this->basic_model->group_by($this->group_by[0], $this->group_by[1]);

if(!empty($this->where))
foreach($this->where as $where)
$this->basic_model->where($where[0],$where[1],$where[2]);
Expand Down Expand Up @@ -3490,13 +3493,14 @@ class Grocery_CRUD extends grocery_CRUD_States
protected $subject_plural = null;
protected $display_as = array();
protected $order_by = null;
protected $group_by = null;
protected $where = array();
protected $like = array();
protected $having = array();
protected $or_having = array();
protected $limit = null;
protected $required_fields = array();
protected $_unique_fields = array();
protected $_unique_fields = array();
protected $validation_rules = array();
protected $relation = array();
protected $relation_n_n = array();
Expand Down Expand Up @@ -4338,6 +4342,13 @@ public function order_by($order_by, $direction = 'asc')
return $this;
}

public function group_by($by, $escape = NULL)
{
$this->group_by = array($by, $escape);

return $this;
}

public function where($key, $value = NULL, $escape = TRUE)
{
$this->where[] = array($key,$value,$escape);
Expand Down