當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。