DataTables / Editor-PHP

PHP server-side libraries for Editor
Other
35 stars 22 forks source link

Group BY #40

Open MrG0LD3 opened 2 months ago

MrG0LD3 commented 2 months ago

No ficheiro Editor.php, adicionar procurar as linhas

/** @var string Action name allowing for configuration */
private $_actionName = 'action';

e adicionar após

/** @var string */
private $_group_by = '';

Adicionar a função

/**
 * @param string $column
 *
 * @return ($column is null ? string[] : $this) Where condition array.
 */
public function groupBy($column) {

    if ($column === null) {
        return $this->_group_by;
    }

    $this->_group_by = $column;

    return $this;
}

Na função private function _get($id = null, $http = null)

Procurar a linha $ssp = $this->_ssp_query($query, $http); e adicionar depois da mesma

if($this->_group_by != '')
    $query->group_by($this->_group_by);

if ($id !== null) {
    $query->where($this->pkeyToArray($id, true));
}

Pode ser sempre melhorada foi uma alteração que fiz para poder usar o group by no editor