Doctrine\DBAL\Query\QueryBuilder::groupBy PHP Method

groupBy() public method

Replaces any previously specified groupings, if any. $qb = $conn->createQueryBuilder() ->select('u.name') ->from('users', 'u') ->groupBy('u.id');
public groupBy ( mixed $groupBy )
$groupBy mixed The grouping expression.
    public function groupBy($groupBy)
    {
        if (empty($groupBy)) {
            return $this;
        }
        $groupBy = is_array($groupBy) ? $groupBy : func_get_args();
        return $this->add('groupBy', $groupBy, false);
    }

Usage Example

Esempio n. 1
0
 /**
  * Build the data query
  *
  * @return QueryBuilder
  */
 public function getDataQuery()
 {
     $this->buildFilteredQuery();
     if ($this->offset !== null) {
         $this->currentQueryBuilder->setFirstResult($this->offset);
     }
     if ($this->length !== null) {
         $this->currentQueryBuilder->setMaxResults($this->length);
     }
     if ($this->orders !== null) {
         foreach ($this->orders as $order) {
             list($column, $dir) = $order;
             $this->currentQueryBuilder->addOrderBy($column->sourceSort, $dir);
         }
     }
     if (isset($this->conf->group)) {
         $this->currentQueryBuilder->groupBy($this->conf->group);
     }
     return $this->currentQueryBuilder;
 }
All Usage Examples Of Doctrine\DBAL\Query\QueryBuilder::groupBy