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


PHP QueryBuilder::orderBy方法代碼示例

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


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

示例1: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     $paramcount = 0;
     if (isset($this->gID) && $this->gID > 0) {
         $query->where('gID = ?')->setParameter($paramcount++, $this->gID);
     }
     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 ($this->search) {
         $query->andWhere('pName like ?')->setParameter($paramcount++, '%' . $this->search . '%');
     }
     return $query;
 }
開發者ID:Rgeelen,項目名稱:vivid_store,代碼行數:30,代碼來源:ProductList.php

示例2: executeSortBy

 protected function executeSortBy($column, $direction = 'asc')
 {
     if (in_array(strtolower($direction), array('asc', 'desc'))) {
         $this->query->orderBy($column, $direction);
     } else {
         throw new \Exception(t('Invalid SQL in order by'));
     }
 }
開發者ID:ppiedaderawnet,項目名稱:concrete5,代碼行數:8,代碼來源:ItemList.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;
         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:pvernaglia,項目名稱:vivid_store,代碼行數:60,代碼來源:ProductList.php

示例4: process

 /**
  * Applies operation to data source and returns modified data source.
  *
  * @param QueryBuilder $src
  * @param OperationInterface|SortOperation $operation
  * @return QueryBuilder
  */
 public function process($src, OperationInterface $operation)
 {
     $field = $operation->getField();
     $order = $operation->getOrder();
     $src->orderBy($field, $order);
     return $src;
 }
開發者ID:view-components,項目名稱:doctrine-data-processing,代碼行數:14,代碼來源:SortProcessor.php

示例5: sort

 /**
  * @param QueryBuilder  $queryBuilder
  * @param SortInterface $sort
  * @param Mapping       $mapping
  */
 public static function sort(QueryBuilder $queryBuilder, SortInterface $sort, Mapping $mapping)
 {
     $columns = $mapping->map();
     foreach ($sort->orders() as $propertyName => $order) {
         self::guardColumnExists($columns, $propertyName);
         $queryBuilder->orderBy($columns[$propertyName], $order->isAscending() ? Order::ASCENDING : Order::DESCENDING);
     }
 }
開發者ID:PHPRepository,項目名稱:sql-repository,代碼行數:13,代碼來源:SqlSorter.php

示例6: finalizeQuery

 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     $paramcount = 0;
     if (isset($this->gID) && $this->gID > 0) {
         $query->where('gID = ?')->setParameter($paramcount++, $this->gID);
     }
     switch ($this->sortBy) {
         case "alpha":
             $query->orderBy('drName', 'ASC');
             break;
     }
     if ($this->search) {
         $query->andWhere('drName like ?')->setParameter($paramcount++, '%' . $this->search . '%');
     }
     $query->andWhere('drDeleted is NULL');
     return $query;
 }
開發者ID:Janoinen,項目名稱:vivid_store,代碼行數:17,代碼來源:DiscountRuleList.php

示例7: match

    /**
     * @see \ComPHPPuebla\Doctrine\TableGateway\Specification\QueryBuilderSpecification::match()
     */
    public function match(QueryBuilder $qb)
    {
        if ($this->has('latitude') && $this->has('longitude')) {
            $qb->addSelect(<<<SELECT
    (6371
    * (2 * ATAN(SQRT(SIN(((:latitude - s.latitude) * (PI()/180))/2) * SIN(((:latitude - s.latitude) * (PI()/180))/2)
    + COS(:latitude * (PI()/180)) * COS(s.latitude * (PI()/180))
    * SIN(((:longitude - s.longitude) * (PI()/180))/2) * SIN(((:longitude - s.longitude) * (PI()/180))/2)),
            SQRT(1-(sin(((:latitude - s.latitude) * (PI()/180))/2) * SIN(((:latitude - s.latitude) * (PI()/180))/2)
    + COS(:latitude * (PI()/180) * COS(s.latitude * (PI()/180)
    * SIN(((:longitude - s.longitude) * (PI()/180))/2) * SIN(((:longitude - s.longitude) * (PI()/180))/2))))))))
    AS distance
SELECT
);
            $qb->orderBy('distance');
            $qb->setParameter('latitude', $this->get('latitude'));
            $qb->setParameter('longitude', $this->get('longitude'));
        }
    }
開發者ID:comphppuebla,項目名稱:echale-gas-api,代碼行數:22,代碼來源:GeolocationSpecification.php

示例8: getQueryBuilder

 /**
  * @return QueryBuilder|null
  */
 public function getQueryBuilder()
 {
     if (is_null($this->queryBuilder)) {
         $this->queryBuilder = new QueryBuilder($this->connection);
         $this->adaptQueryBuilder($this->queryBuilder);
         // Apply filters
         $filters = $this->getFilterBuilder()->getCurrentFilters();
         foreach ($filters as $filter) {
             /* @var AbstractDBALFilterType $type */
             $type = $filter->getType();
             $type->setQueryBuilder($this->queryBuilder);
             $filter->apply();
         }
         // Apply sorting
         if (!empty($this->orderBy)) {
             $orderBy = $this->orderBy;
             $this->queryBuilder->orderBy($orderBy, $this->orderDirection == 'DESC' ? 'DESC' : 'ASC');
         }
     }
     return $this->queryBuilder;
 }
開發者ID:headonkeyboard,項目名稱:KunstmaanBundlesCMS,代碼行數:24,代碼來源:AbstractDoctrineDBALAdminListConfigurator.php

示例9: orderBy

 /**
  * Specifies an ordering for the query results.
  * Replaces any previously specified orderings, if any.
  *
  * @param string $sort The ordering expression.
  * @param string $order The ordering direction.
  * @return QueryBuilder This QueryBuilder instance.
  */
 public function orderBy($sort, $order = null)
 {
     $connection = $this->getConnection();
     return parent::orderBy($connection->quoteIdentifier($sort), $order);
 }
開發者ID:GruppoMeta,項目名稱:Movio,代碼行數:13,代碼來源:QueryBuilder.php

示例10: setLimitOrder

 /**
  * Conditionally add LIMIT and ORDER BY to a QueryBuilder query.
  *
  * @param QueryBuilder $query
  * @param array        $options Additional options:
  *                              - 'limit' (integer):     Maximum number of results to return
  *                              - 'order' (string):      Field to order by
  *                              - 'direction' (string):  ASC or DESC
  *                              - 'contentid' (integer): Filter further by content ID
  *                              - 'id' (integer):        Filter by a specific change log entry ID
  */
 protected function setLimitOrder(QueryBuilder $query, array $options)
 {
     if (isset($options['order'])) {
         $query->orderBy($options['order'], $options['direction']);
     }
     if (isset($options['limit'])) {
         $query->setMaxResults(intval($options['limit']));
         if (isset($options['offset'])) {
             $query->setFirstResult(intval($options['offset']));
         }
     }
 }
開發者ID:nectd,項目名稱:nectd-web,代碼行數:23,代碼來源:LogChangeRepository.php

示例11: _loadResult

 /**
  * 加載數據庫結果集
  *
  * @param  bool $multiple 是否加載多行數據
  * @return $this|mixed
  */
 protected function _loadResult($multiple = false)
 {
     $this->_dbBuilder->from($this->db()->quoteIdentifier($this->_tableName), $this->db()->quoteIdentifier($this->_objectName));
     // 隻獲取單條記錄
     if (false === $multiple) {
         $this->_dbBuilder->setMaxResults(1);
     }
     // 默認選擇所有字段
     $this->_dbBuilder->addSelect($this->_buildSelect());
     // 處理排序問題
     if (!isset($this->_dbApplied['orderBy']) && !empty($this->_sorting)) {
         foreach ($this->_sorting as $column => $direction) {
             if (false === strpos($column, '.')) {
                 // Sorting column for use in JOINs
                 $column = $this->_objectName . '.' . $column;
             }
             $this->_dbBuilder->orderBy($column, $direction);
         }
     }
     if (true === $multiple) {
         $result = $this->_dbBuilder->execute();
         $result->setFetchMode(PDO::FETCH_CLASS, $this->_loadMultiResultFetcherClass(), $this->_loadMultiResultFetcherConstructor());
         $this->reset();
         return $result->fetchAll();
     } else {
         $result = $this->_dbBuilder->execute()->fetch();
         $this->reset();
         if ($result) {
             $this->_loadValues($result);
         } else {
             $this->clear();
         }
         return $this;
     }
 }
開發者ID:tourze,項目名稱:model,代碼行數:41,代碼來源:Model.php

示例12: orderByQuotesIdentifierAndDelegatesToConcreteQueryBuilder

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

示例13: orderBy

 /**
  * {@inheritdoc}
  */
 public function orderBy($field, $direction)
 {
     return $this->queryBuilder->orderBy($field, $direction);
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:7,代碼來源:ExpressionBuilder.php

示例14: modifyTimeDataQuery

 /**
  * Modify database query for fetching the line time chart data
  *
  * @param  QueryBuilder $query
  * @param  string       $column name
  * @param  string       $tablePrefix
  */
 public function modifyTimeDataQuery(&$query, $column, $tablePrefix = 't')
 {
     // Convert time unitst to the right form for current database platform
     $dbUnit = $this->translateTimeUnit($this->unit);
     $limit = $this->countAmountFromDateRange($this->unit);
     $groupBy = '';
     if (isset($filters['groupBy'])) {
         $groupBy = ', ' . $tablePrefix . '.' . $filters['groupBy'];
         unset($filters['groupBy']);
     }
     $dateConstruct = 'DATE_FORMAT(' . $tablePrefix . '.' . $column . ', \'' . $dbUnit . '\')';
     $query->select($dateConstruct . ' AS date, COUNT(*) AS count')->groupBy($dateConstruct . $groupBy);
     $query->orderBy($dateConstruct, 'ASC')->setMaxResults($limit);
 }
開發者ID:Yame-,項目名稱:mautic,代碼行數:21,代碼來源:ChartQuery.php

示例15: orderBy

 /**
  * Specifies an ordering for the query results.
  * Replaces any previously specified orderings, if any.
  *
  * @param string $sort The ordering expression.
  * @param string $order The ordering direction.
  *
  * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
  */
 public function orderBy($sort, $order = null)
 {
     $this->queryBuilder->orderBy($this->helper->quoteColumnName($sort), $order);
     return $this;
 }
開發者ID:rchicoli,項目名稱:owncloud-core,代碼行數:14,代碼來源:QueryBuilder.php


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