当前位置: 首页>>代码示例>>PHP>>正文


PHP QueryBuilder::getQueryPart方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Query\QueryBuilder::getQueryPart方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::getQueryPart方法的具体用法?PHP QueryBuilder::getQueryPart怎么用?PHP QueryBuilder::getQueryPart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Query\QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::getQueryPart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDistinct

 /**
  * Returns the sql expression to determinate the distincts numbers of lines
  *
  * @return string
  */
 protected function getDistinct()
 {
     if (isset($this->conf->group)) {
         return $this->conf->group;
     }
     return implode(', ', $this->queryBuilder->getQueryPart('select'));
 }
开发者ID:solire,项目名称:trieur,代码行数:12,代码来源:Doctrine.php

示例2: getTotal

 /**
  * @return bool|string
  */
 public function getTotal()
 {
     if ($this->total) {
         return $this->total;
     }
     $queryBuilder = $this->repository->getEm()->createQueryBuilder();
     $fromParts = $this->queryBuilder->getQueryPart('from');
     if ($fromParts) {
         foreach ($fromParts as $from) {
             $queryBuilder->from($from['table'], $from['alias']);
         }
     }
     $queryBuilder->select('COUNT(*)');
     $where = $this->queryBuilder->getQueryPart('where');
     if ($where) {
         $queryBuilder->add('where', (string) $where);
     }
     $parameters = $this->queryBuilder->getParameters();
     if ($parameters) {
         foreach ($parameters as $key => $value) {
             $queryBuilder->setParameter($key, $value);
         }
     }
     return $this->total = $queryBuilder->execute()->fetchColumn();
 }
开发者ID:lynx,项目名称:lynx,代码行数:28,代码来源:RepositoryPaginator.php

示例3: hasJoinAlias

 /**
  * {@inheritDoc}
  */
 public function hasJoinAlias($joinAlias)
 {
     $joinParts = $this->queryBuilder->getQueryPart('join');
     foreach ($joinParts as $rootAlias => $joins) {
         foreach ($joins as $join) {
             if ($join['joinAlias'] === $joinAlias) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:11ya,项目名称:LexikFormFilterBundle,代码行数:15,代码来源:DBALQuery.php

示例4: incorporateDbalQueryBuilder

 /**
  * @internal
  */
 private function incorporateDbalQueryBuilder(QueryBuilder $qb, FilterInterface $filter)
 {
     $criteria = $this->getFilteringCriteria($filter);
     // extraindo os rootAliases, pois o DBAL\QueryBuilder não tem
     $fromPart = $qb->getQueryPart('from');
     $rootAliases = array();
     foreach ($fromPart as $part) {
         $rootAliases[] = $part['alias'];
     }
     $visitor = new DbalQueryExpressionVisitor($qb->getConnection(), $rootAliases, $this->fieldMap);
     if ($whereExpression = $criteria->getWhereExpression()) {
         $qb->andWhere($visitor->dispatch($whereExpression));
         $qb->setParameters($visitor->getParameters());
     }
     if ($criteria->getOrderings()) {
         foreach ($criteria->getOrderings() as $sort => $order) {
             $qb->addOrderBy($visitor->getFieldName($sort), $order);
         }
     }
     if (($firstResult = $criteria->getFirstResult()) !== null) {
         $qb->setFirstResult($firstResult);
     }
     if (($maxResults = $criteria->getMaxResults()) !== null) {
         $qb->setMaxResults($maxResults);
     }
 }
开发者ID:brodaproject,项目名称:broda,代码行数:29,代码来源:DbalQueryBuilderIncorporator.php

示例5: load

 /**
  * For repeating fields, the load method adds extra joins and selects to the query that
  * fetches the related records from the field and field value tables in the same query as the content fetch.
  *
  * @param QueryBuilder  $query
  * @param ClassMetadata $metadata
  *
  * @return void
  */
 public function load(QueryBuilder $query, ClassMetadata $metadata)
 {
     $field = $this->mapping['fieldname'];
     $boltname = $metadata->getBoltName();
     $from = $query->getQueryPart('from');
     if (isset($from[0]['alias'])) {
         $alias = $from[0]['alias'];
     } else {
         $alias = $from[0]['table'];
     }
     $query->addSelect($this->getPlatformGroupConcat('fields', $query))->leftJoin($alias, $this->mapping['tables']['field_value'], 'f', "f.content_id = {$alias}.id AND f.contenttype='{$boltname}' AND f.name='{$field}'");
 }
开发者ID:MenZil-Team,项目名称:bolt,代码行数:21,代码来源:RepeaterType.php

示例6: load

 /**
  * For relations, the load method adds an extra ->addSelect() and ->leftJoin() to the query that
  * fetches the related records from the join table in the same query as the content fetch.
  *
  * IDs are returned comma-separated which the ->hydrate() method can then turn into pointers
  * to the related entities.
  *
  * @param QueryBuilder  $query
  * @param ClassMetadata $metadata
  */
 public function load(QueryBuilder $query, ClassMetadata $metadata)
 {
     $field = $this->mapping['fieldname'];
     $target = $this->mapping['target'];
     $boltname = $metadata->getBoltName();
     $from = $query->getQueryPart('from');
     if (isset($from[0]['alias'])) {
         $alias = $from[0]['alias'];
     } else {
         $alias = $from[0]['table'];
     }
     $query->addSelect($this->getPlatformGroupConcat("{$field}.to_id", $field, $query))->leftJoin($alias, $target, $field, "{$alias}.id = {$field}.from_id AND {$field}.from_contenttype='{$boltname}' AND {$field}.to_contenttype='{$field}'")->addGroupBy("{$alias}.id");
 }
开发者ID:nuffer,项目名称:bolt,代码行数:23,代码来源:RelationType.php

示例7: addAdditonalWhereConditions

 /**
  * Add the additional query conditions returned by the QueryRestrictionBuilder
  * to the current query and return the original set of conditions so that they
  * can be restored after the query has been built/executed.
  *
  * @return \Doctrine\DBAL\Query\Expression\CompositeExpression|mixed
  */
 protected function addAdditonalWhereConditions()
 {
     $queryRestrictionBuilder = GeneralUtility::makeInstance(QueryRestrictionBuilder::class, $this->getQueriedTables(), $this->expr(), $this->getQueryContext());
     $originalWhereConditions = $this->concreteQueryBuilder->getQueryPart('where');
     if ($originalWhereConditions instanceof CompositeExpression) {
         $originalWhereConditions = clone $originalWhereConditions;
     }
     $additionalQueryRestrictions = $queryRestrictionBuilder->getVisibilityConstraints();
     if ($additionalQueryRestrictions->count() !== 0) {
         // save the original query conditions so we can restore
         // them after the query has been built.
         $this->concreteQueryBuilder->andWhere($additionalQueryRestrictions);
     }
     return $originalWhereConditions;
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:22,代码来源:QueryBuilder.php

示例8: load

 /**
  * @inheritdoc
  */
 public function load(QueryBuilder $query, ClassMetadata $metadata)
 {
     $field = $this->mapping['fieldname'];
     $boltname = $metadata->getBoltName();
     if ($this->mapping['data']['has_sortorder']) {
         $order = "{$field}.sortorder";
     } else {
         $order = "{$field}.id";
     }
     $from = $query->getQueryPart('from');
     if (isset($from[0]['alias'])) {
         $alias = $from[0]['alias'];
     } else {
         $alias = $from[0]['table'];
     }
     $query->addSelect($this->getPlatformGroupConcat("{$field}.slug", $order, $field, $query))->leftJoin($alias, 'bolt_taxonomy', $field, "{$alias}.id = {$field}.content_id AND {$field}.contenttype='{$boltname}' AND {$field}.taxonomytype='{$field}'")->addGroupBy("{$alias}.id");
 }
开发者ID:nectd,项目名称:nectd-web,代码行数:20,代码来源:TaxonomyType.php

示例9: preprocess

 /**
  * Preprocess and execute SELECT query.
  *
  * @param \Doctrine\DBAL\Query\QueryBuilder $qb
  *
  * @throws \Lokhman\Silex\ARM\Exception\RepositoryException
  * @return \Doctrine\DBAL\Driver\Statement
  */
 private function preprocess(QueryBuilder $qb)
 {
     // for each FROM part in QueryBuilder
     foreach ($qb->getQueryPart('from') as $part) {
         $table = $table = $this->prefix . $part['table'];
         if (!isset($this->app['arm'][$table])) {
             self::raise('No repository registered for "' . $table . '".');
         }
         $tables[$part['alias']] = $this->app['arm'][$table];
     }
     // for each JOIN part in QueryBuilder
     foreach ($qb->getQueryPart('join') as $part) {
         $table = $this->prefix . $part[0]['joinTable'];
         if (!isset($this->app['arm'][$table])) {
             self::raise('No repository registered for "' . $table . '".');
         }
         $tables[$part[0]['joinAlias']] = $this->app['arm'][$table];
     }
     // re-define select columns
     $qb->select($this->formatSelect($qb, $tables));
     // execute pre-formatted SELECT query ( $qb->execute() )
     return $this->db->executeQuery($this->formatQuery($qb, $tables), $qb->getParameters(), $qb->getParameterTypes());
 }
开发者ID:lokhman,项目名称:silex-arm,代码行数:31,代码来源:Repository.php

示例10: addTotalCountSelect

 /**
  * Modifies the passed DBAL query builder object to calculate
  * the total count.
  *
  * @param QueryBuilder $builder
  * @return $this
  */
 private function addTotalCountSelect(QueryBuilder $builder)
 {
     $select = $builder->getQueryPart('select');
     $select[0] = ' SQL_CALC_FOUND_ROWS ' . $select[0];
     $builder->select($select);
     return $this;
 }
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:14,代码来源:Result.php

示例11: getQueryPartDelegatesToConcreteQueryBuilder

 /**
  * @test
  */
 public function getQueryPartDelegatesToConcreteQueryBuilder()
 {
     $this->concreteQueryBuilder->getQueryPart('from')->shouldBeCalled()->willReturn('aTable');
     $this->subject->getQueryPart('from');
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:8,代码来源:QueryBuilderTest.php

示例12: 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

示例13: getQueryPart

 /**
  * Gets a query part by its name.
  *
  * @param string $queryPartName
  *
  * @return mixed
  */
 public function getQueryPart($queryPartName)
 {
     return $this->queryBuilder->getQueryPart($queryPartName);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:11,代码来源:QueryBuilder.php

示例14: hasQueryBuilderJoins

 private function hasQueryBuilderJoins(QueryBuilder $queryBuilder)
 {
     $joins = $queryBuilder->getQueryPart('join');
     return !empty($joins);
 }
开发者ID:3lolo,项目名称:lr_app,代码行数:5,代码来源:DoctrineDbalSingleTableAdapter.php

示例15: setLastInsertId

 /**
  * @TODO Temporary workaround for PostgreSQL databases that don't use a sequence.
  *
  * @param QueryBuilder $query
  */
 private function setLastInsertId(QueryBuilder $query)
 {
     $seq = null;
     if ($query->getConnection()->getDatabasePlatform()->getName() === 'postgresql') {
         $sequences = $query->getConnection()->getSchemaManager()->listSequences();
         $desiredSeq = $query->getQueryPart('from')['table'] . '_id_seq';
         foreach ($sequences as $sequence) {
             if ($desiredSeq === $sequence->getName()) {
                 $seq = $desiredSeq;
                 break;
             }
         }
     }
     $this->lastInsertId = $query->getConnection()->lastInsertId($seq);
 }
开发者ID:gandalf3,项目名称:bolt,代码行数:20,代码来源:QuerySet.php


注:本文中的Doctrine\DBAL\Query\QueryBuilder::getQueryPart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。