Fields can be passed as an array of strings, array of expression
objects, a single expression or a single string.
By default this function will append any passed argument to the list of fields
to be grouped, unless the second argument is set to true.
### Examples:
Produces GROUP BY id, title
$query->group(['id', 'title']);
Produces GROUP BY title
$query->group('title');
/** * Returns the passed query after rewriting the DISTINCT clause, so that drivers * that do not support the "ON" part can provide the actual way it should be done * * @param \Cake\Database\Query $query The query to be transformed * @return \Cake\Database\Query */ protected function _transformDistinct($query) { if (is_array($query->clause('distinct'))) { $query->group($query->clause('distinct'), true); $query->distinct(false); } return $query; }
public function beforeFind(Event $event, Query $query, ArrayObject $options) { $query->join(['table' => 'pessoas_associacoes', 'alias' => 'PessoasAssociacoes', 'type' => 'INNER', 'conditions' => ['PessoasAssociacoes.pessoa_id = ' . $this->aliasField('pessoa_id'), 'PessoasAssociacoes.tipo_associacao' => 7, 'PessoasAssociacoes.status !=' => 9]]); $query->group($this->aliasField('pessoa_id')); }