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


PHP ORM\Query类代码示例

本文整理汇总了PHP中Doctrine\ORM\Query的典型用法代码示例。如果您正苦于以下问题:PHP Query类的具体用法?PHP Query怎么用?PHP Query使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: rewind

 /**
  * {@inheritdoc}
  */
 public function rewind()
 {
     if (!$this->iterableResult) {
         $this->iterableResult = $this->query->iterate(array(), Query::HYDRATE_ARRAY);
     }
     $this->iterableResult->rewind();
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:10,代码来源:DoctrineQueryReader.php

示例2: getSlice

 /**
  * {@inheritdoc}
  */
 public function getSlice($offset, $length)
 {
     $query = clone $this->query;
     $query->setParameters($this->query->getParameters());
     $query->setFirstResult($offset)->setMaxResults($length);
     return $query->getQuery()->getResult();
 }
开发者ID:olegstepura,项目名称:doctrine-multicolumn-search,代码行数:10,代码来源:PagerfantaAdapter.php

示例3: __construct

 /**
  * Constructor.
  *
  * Stores various parameters that are otherwise unavailable
  * because Doctrine\ORM\Query\SqlWalker keeps everything private without
  * accessors.
  *
  * @param \Doctrine\ORM\Query              $query
  * @param \Doctrine\ORM\Query\ParserResult $parserResult
  * @param array                            $queryComponents
  */
 public function __construct($query, $parserResult, array $queryComponents)
 {
     $this->platform = $query->getEntityManager()->getConnection()->getDatabasePlatform();
     $this->rsm = $parserResult->getResultSetMapping();
     $this->queryComponents = $queryComponents;
     parent::__construct($query, $parserResult, $queryComponents);
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:18,代码来源:CountOutputWalker.php

示例4: addHint

 /**
  * Adds a hint to a query object
  *
  * @param Query  $query
  * @param string $name
  * @param mixed  $value
  *
  * @return bool TRUE if the hint is added; otherwise, FALSE
  */
 public function addHint(Query $query, $name, $value)
 {
     $result = false;
     if ($name === Query::HINT_CUSTOM_TREE_WALKERS) {
         $walkers = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);
         if (false === $walkers) {
             $walkers = [$value];
             $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $walkers);
             $result = true;
         } elseif (!in_array($value, $walkers, true)) {
             $walkers[] = $value;
             $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $walkers);
             $result = true;
         }
     } elseif ($name === Query::HINT_CUSTOM_OUTPUT_WALKER) {
         if ($query->getHint($name) !== $value) {
             $query->setHint($name, $value);
             $result = true;
         }
     } else {
         $query->setHint($name, $value);
         $result = true;
     }
     return $result;
 }
开发者ID:Maksold,项目名称:platform,代码行数:34,代码来源:QueryHintResolver.php

示例5: apply

 /**
  * Apply ACL filter
  *
  * @param  QueryBuilder | Query   $query
  * @param  array                  $permissions
  * @param  string | UserInterface $identity
  * @param  string                 $alias
  * @param  array|Query|QueryBuilder $extraCriteria
  *
  * @return Query
  */
 public function apply($query, array $permissions = array('VIEW'), $identity = null, $alias = null, $extraCriteria = false)
 {
     if (null === $identity) {
         $token = $this->securityContext->getToken();
         $identity = $token->getUser();
     }
     $query->setHint(static::HINT_ACL_EXTRA_CRITERIA, $this->getExtraCriteria($extraCriteria));
     if ($query instanceof QueryBuilder) {
         $query = $this->cloneQuery($query->getQuery());
     } elseif ($query instanceof Query) {
         $query = $this->cloneQuery($query);
     } else {
         throw new \Exception();
     }
     $maskBuilder = new MaskBuilder();
     foreach ($permissions as $permission) {
         $mask = constant(get_class($maskBuilder) . '::MASK_' . strtoupper($permission));
         $maskBuilder->add($mask);
     }
     $entity = $this->getEntityFromAlias($query, $alias);
     $metadata = $entity['metadata'];
     $alias = $entity['alias'];
     $table = $metadata->getQuotedTableName($this->em->getConnection()->getDatabasePlatform());
     $aclQuery = $this->getExtraQuery($this->getClasses($metadata), $this->getIdentifiers($identity), $maskBuilder->get());
     $hintAclMetadata = false !== $query->getHint('acl.metadata') ? $query->getHint('acl.metadata') : array();
     $hintAclMetadata[] = array('query' => $aclQuery, 'table' => $table, 'alias' => $alias);
     $query->setHint('acl.metadata', $hintAclMetadata);
     $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, $this->aclWalker);
     return $query;
 }
开发者ID:Codenetz,项目名称:AclBundle,代码行数:41,代码来源:AclFilter.php

示例6: processParameterMappings

 /**
  * @param Query                              $query
  * @param array                              $paramMappings
  * @return array
  * @throws \Doctrine\ORM\Query\QueryException
  */
 protected function processParameterMappings(Query $query, $paramMappings)
 {
     $sqlParams = array();
     $types = array();
     /** @var Parameter $parameter */
     foreach ($query->getParameters() as $parameter) {
         $key = $parameter->getName();
         if (!isset($paramMappings[$key])) {
             throw QueryException::unknownParameter($key);
         }
         $value = $query->processParameterValue($parameter->getValue());
         $type = $parameter->getValue() === $value ? $parameter->getType() : Query\ParameterTypeInferer::inferType($value);
         foreach ($paramMappings[$key] as $position) {
             $types[$position] = $type;
         }
         $sqlPositions = $paramMappings[$key];
         $value = array($value);
         $countValue = count($value);
         for ($i = 0, $l = count($sqlPositions); $i < $l; $i++) {
             $sqlParams[$sqlPositions[$i]] = $value[$i % $countValue];
         }
     }
     if (count($sqlParams) != count($types)) {
         throw QueryException::parameterTypeMissmatch();
     }
     if ($sqlParams) {
         ksort($sqlParams);
         $sqlParams = array_values($sqlParams);
         ksort($types);
         $types = array_values($types);
     }
     return array($sqlParams, $types);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:39,代码来源:QueryCountCalculator.php

示例7: getItemCount

 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function getItemCount()
 {
     try {
         return array_sum(array_map('current', $this->countQuery->getScalarResult()));
     } catch (NoResultException $e) {
         return 0;
     }
 }
开发者ID:kgilden,项目名称:pager,代码行数:13,代码来源:DqlByHandAdapter.php

示例8: applyTranslatorGedmoHints

 /**
  * @param Query $query
  */
 protected function applyTranslatorGedmoHints(Query &$query)
 {
     if (BELCEBUR_GEDMO_TRANSLATION_LOCALE !== 'BELCEBUR_GEDMO_TRANSLATION_LOCALE') {
         $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, $this->gedmoWalker);
         $query->setHint(TranslatableListener::HINT_TRANSLATABLE_LOCALE, BELCEBUR_GEDMO_TRANSLATION_LOCALE);
         $query->setHint(TranslatableListener::HINT_FALLBACK, TRUE);
     }
 }
开发者ID:Belcebur,项目名称:BelceburBasic,代码行数:11,代码来源:EntityRepositoryTranslatable.php

示例9: __construct

 public function __construct(DoctrineOrmPaginator $paginator)
 {
     $this->paginator = $paginator;
     $this->query = $paginator->getQuery();
     $this->firstResult = $this->query->getFirstResult();
     $this->maxResults = $this->query->getMaxResults();
     $this->totalItems = count($paginator);
 }
开发者ID:reminec,项目名称:DunglasApiBundle,代码行数:8,代码来源:Paginator.php

示例10: processMostSearchedQuery

 /**
  * @param Query $query
  *
  * @return array
  */
 protected function processMostSearchedQuery(Query $query)
 {
     $resultQuery = $query->getArrayResult();
     $result = [];
     foreach ($resultQuery as $answerArray) {
         $result[] = ['title' => $answerArray['title'], 'description' => $answerArray['description'], 'uri' => $this->routerInterface->generate('aalto_api_answer_show', ['slug' => $answerArray['slug']])];
     }
     return $result;
 }
开发者ID:Neirda24,项目名称:Aalto,代码行数:14,代码来源:AnswerManager.php

示例11: setTranslatableQueryHints

 /**
  * @param Query $query
  * @param string $locale
  * @throws \Exception
  */
 protected function setTranslatableQueryHints(Query $query, $locale)
 {
     if (!class_exists('Gedmo\\Translatable\\TranslatableListener')) {
         throw new \Exception('"Translatable" extension missing. "stof/doctrine-extensions-bundle" needs to be installed');
     }
     $query->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE, $locale);
     $query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_FALLBACK, 1);
 }
开发者ID:byteworks-ch,项目名称:AstinaLabelsBundle,代码行数:14,代码来源:TranslatedLabelSearch.php

示例12: addCustomTreeWalker

 /**
  * Add a custom TreeWalker $walker class name to
  * be included in the CustomTreeWalker hint list
  * of the given $query
  *
  * @param Query $query
  * @param string $walker
  * @return void
  */
 public static function addCustomTreeWalker(Query $query, $walker)
 {
     $customTreeWalkers = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);
     if ($customTreeWalkers !== false && is_array($customTreeWalkers)) {
         $customTreeWalkers = array_merge($customTreeWalkers, array($walker));
     } else {
         $customTreeWalkers = array($walker);
     }
     $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $customTreeWalkers);
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:19,代码来源:Helper.php

示例13: cloneQuery

 /**
  * Clones a query
  * @param Query $query the query to be cloned
  * @return \Query the new query
  */
 private function cloneQuery($query)
 {
     /* @var $cloneQuery Query */
     $cloneQuery = clone $query;
     $cloneQuery->setParameters(clone $query->getParameters());
     foreach ($query->getHints() as $name => $value) {
         $cloneQuery->setHint($name, $value);
     }
     return $cloneQuery;
 }
开发者ID:sandrineBeauche,项目名称:cookbookServer,代码行数:15,代码来源:Paginator.php

示例14: cloneQuery

 /**
  * @param Query $query
  * @return Query
  */
 protected static function cloneQuery(Query $query)
 {
     /* @var $countQuery Query */
     $countQuery = clone $query;
     $params = $query->getParameters();
     foreach ($params as $key => $param) {
         $countQuery->setParameter($key, $param);
     }
     return $countQuery;
 }
开发者ID:Clansuite,项目名称:Clansuite,代码行数:14,代码来源:Paginate.php

示例15: setMaxPerPage

 /**
  * @param int $maxPerPage
  */
 public function setMaxPerPage($maxPerPage)
 {
     if ($maxPerPage > 0) {
         $this->maxPerPage = $maxPerPage;
         $this->query->setMaxResults($maxPerPage);
     } else {
         $this->maxPerPage = 0;
         $this->query->setMaxResults(Query::INFINITY);
     }
     $this->calculateFirstResult();
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:14,代码来源:IndexerPager.php


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