當前位置: 首頁>>代碼示例>>PHP>>正文


PHP QueryBuilder::groupBy方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Query\QueryBuilder::groupBy方法的典型用法代碼示例。如果您正苦於以下問題:PHP QueryBuilder::groupBy方法的具體用法?PHP QueryBuilder::groupBy怎麽用?PHP QueryBuilder::groupBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Query\QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::groupBy方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getDataQuery

 /**
  * 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;
 }
開發者ID:solire,項目名稱:trieur,代碼行數:25,代碼來源:Doctrine.php

示例2: groupByQuotesIdentifierAndDelegatesToConcreteQueryBuilder

 /**
  * @test
  */
 public function groupByQuotesIdentifierAndDelegatesToConcreteQueryBuilder()
 {
     $this->connection->quoteIdentifiers(['aField', 'anotherField'])->shouldBeCalled()->willReturnArgument(0);
     $this->concreteQueryBuilder->groupBy('aField', 'anotherField')->shouldBeCalled()->willReturn($this->subject);
     $this->subject->groupBy('aField', 'anotherField');
 }
開發者ID:dachcom-digital,項目名稱:TYPO3.CMS,代碼行數:9,代碼來源:QueryBuilderTest.php

示例3: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     $paramcount = 0;
     if (!empty($this->gIDs)) {
         $validgids = array();
         foreach ($this->gIDs as $gID) {
             if ($gID > 0) {
                 $validgids[] = $gID;
             }
         }
         if (!empty($validgids)) {
             $query->innerJoin('p', 'VividStoreProductGroups', 'g', 'p.pID = g.pID and g.gID in (' . implode(',', $validgids) . ')');
             if (!$this->groupMatchAny) {
                 $query->having('count(g.gID) = ' . count($validgids));
             }
         }
     }
     switch ($this->sortBy) {
         case "alpha":
             $query->orderBy('pName', 'ASC');
             break;
         case "date":
             $query->orderBy('pDateAdded', 'DESC');
             break;
     }
     switch ($this->featured) {
         case "featured":
             $query->andWhere("pFeatured = 1");
             break;
         case "nonfeatured":
             $query->andWhere("pFeatured = 0");
             break;
     }
     if ($this->activeOnly) {
         $query->andWhere("pActive = 1");
     }
     if (is_array($this->cIDs) && !empty($this->cIDs)) {
         $query->innerJoin('p', 'VividStoreProductLocations', 'l', 'p.pID = l.pID and l.cID in (' . implode(',', $this->cIDs) . ')');
     }
     $query->groupBy('p.pID');
     if ($this->search) {
         $query->andWhere('pName like ?')->setParameter($paramcount++, '%' . $this->search . '%');
     }
     return $query;
 }
開發者ID:Janoinen,項目名稱:vivid_store,代碼行數:45,代碼來源:ProductList.php

示例4: groupBy

 public function groupBy($groupBy)
 {
     $connection = $this->getConnection();
     return parent::groupBy($connection->quoteIdentifier($groupBy));
 }
開發者ID:GruppoMeta,項目名稱:Movio,代碼行數:5,代碼來源:QueryBuilder.php

示例5: groupBy

 /**
  * Specifies a grouping over the results of the query.
  * Replaces any previously specified groupings, if any.
  *
  * @param mixed $groupBy The grouping expression.
  *
  * @return self
  */
 public function groupBy($groupBy)
 {
     $this->qb->groupBy($groupBy);
     return $this;
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:13,代碼來源:SqlQueryBuilder.php

示例6: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     $paramcount = 0;
     if (!empty($this->gIDs)) {
         $validgids = array();
         foreach ($this->gIDs as $gID) {
             if ($gID > 0) {
                 $validgids[] = $gID;
             }
         }
         if (!empty($validgids)) {
             $query->innerJoin('p', 'VividStoreProductGroups', 'g', 'p.pID = g.pID and g.gID in (' . implode(',', $validgids) . ')');
             if (!$this->groupMatchAny) {
                 $query->having('count(g.gID) = ' . count($validgids));
             }
         }
     }
     switch ($this->sortBy) {
         case "alpha":
             $query->orderBy('pName', 'ASC');
             break;
         case "date":
             $query->orderBy('pDateAdded', 'DESC');
             break;
         case "pricelth":
             $query->orderBy('pPrice', 'ASC');
             break;
         case "pricehtl":
             $query->orderBy('pPrice', 'DESC');
             break;
         case "popular":
             $pr = new StoreProductReport();
             $pr->sortByPopularity();
             $products = $pr->getProducts();
             $pIDs = array();
             foreach ($products as $product) {
                 $pIDs[] = $product['pID'];
             }
             foreach ($pIDs as $pID) {
                 $query->addOrderBy("pID = ?", 'DESC')->setParameter($paramcount++, $pID);
             }
             break;
     }
     switch ($this->featured) {
         case "featured":
             $query->andWhere("pFeatured = 1");
             break;
         case "nonfeatured":
             $query->andWhere("pFeatured = 0");
             break;
     }
     if (!$this->showOutOfStock) {
         $query->andWhere("pQty > 0 OR pQtyUnlim = 1");
     }
     if ($this->activeOnly) {
         $query->andWhere("pActive = 1");
     }
     if (is_array($this->cIDs) && !empty($this->cIDs)) {
         $query->innerJoin('p', 'VividStoreProductLocations', 'l', 'p.pID = l.pID and l.cID in (' . implode(',', $this->cIDs) . ')');
     }
     $query->groupBy('p.pID');
     if ($this->search) {
         $query->andWhere('pName like ?')->setParameter($paramcount++, '%' . $this->search . '%');
     }
     return $query;
 }
開發者ID:vividweb,項目名稱:vivid_store,代碼行數:66,代碼來源:ProductList.php

示例7: applySearchQueryRelationship

 /**
  * @param QueryBuilder $q
  * @param array        $tables          $tables[0] should be primary table
  * @param bool         $innerJoinTables
  * @param null         $whereExpression
  * @param null         $having
  */
 protected function applySearchQueryRelationship(QueryBuilder $q, array $tables, $innerJoinTables, $whereExpression = null, $having = null)
 {
     $primaryTable = $tables[0];
     unset($tables[0]);
     $joinType = $innerJoinTables ? 'join' : 'leftJoin';
     $this->useDistinctCount = true;
     $joins = $q->getQueryPart('join');
     if (!array_key_exists($primaryTable['alias'], $joins)) {
         $q->{$joinType}($primaryTable['from_alias'], MAUTIC_TABLE_PREFIX . $primaryTable['table'], $primaryTable['alias'], $primaryTable['condition']);
         foreach ($tables as $table) {
             $q->{$joinType}($table['from_alias'], MAUTIC_TABLE_PREFIX . $table['table'], $table['alias'], $table['condition']);
         }
         if ($whereExpression) {
             $q->andWhere($whereExpression);
         }
         if ($having) {
             $q->andHaving($having);
         }
         $q->groupBy('l.id');
     }
 }
開發者ID:dongilbert,項目名稱:mautic,代碼行數:28,代碼來源:LeadRepository.php


注:本文中的Doctrine\DBAL\Query\QueryBuilder::groupBy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。