Gdn_SQLDriver::groupBy PHP Méthode

groupBy() public méthode

Adds to the $this->_GroupBys collection.
public groupBy ( mixed $Fields = null ) : Gdn_SQLDriver
$Fields mixed An array of field names (or a comma-delimited list of field names) to be grouped by.
Résultat Gdn_SQLDriver $this
    public function groupBy($Fields = null)
    {
        if (is_null($Fields)) {
            // Group by every item in the select that isn't a function.
            foreach ($this->_Selects as $Alias => $Select) {
                if (val('Function', $Select) == '') {
                    $this->_GroupBys[] = $Select['Field'];
                }
            }
            return $this;
        }
        if (is_string($Fields)) {
            $Fields = explode(',', $Fields);
        }
        foreach ($Fields as $Field) {
            $Field = trim($Field);
            if ($Field != '') {
                $this->_GroupBys[] = $this->escapeIdentifier($Field);
            }
        }
        return $this;
    }