• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ORM\Query类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getSingleResult

 private function getSingleResult(Query $query)
 {
     try {
         $result = $query->getSingleResult();
     } catch (NonUniqueResultException $e) {
         $result = null;
     } catch (NoResultException $e) {
         $result = null;
     }
     return $result;
 }
开发者ID:sonu27,项目名称:REST-api-test,代码行数:11,代码来源:UserRepository.php


示例17: normalize

 /**
  * @inheritdoc
  */
 public function normalize(Query $query, QueryBuilder $queryBuilder, $hydratorClass = null)
 {
     /*
      * Add custom hydrator
      */
     $emConfig = $queryBuilder->getEntityManager()->getConfiguration();
     $hydrator = new \ReflectionClass($hydratorClass);
     $hydratorName = $hydrator->getShortName();
     $emConfig->addCustomHydrationMode($hydratorName, $hydratorClass);
     return $query->getResult($hydratorName);
 }
开发者ID:mops1k,项目名称:KitpagesDataGridBundle,代码行数:14,代码来源:StandardNormalizer.php


示例18: getQuery

 /**
  * @param \Kdyby\Persistence\Queryable $repository
  *
  * @throws UnexpectedValueException
  * @return \Doctrine\ORM\Query
  */
 protected function getQuery(Queryable $repository)
 {
     $query = $this->toQuery($this->doCreateQuery($repository));
     if ($this->lastQuery && $this->lastQuery->getDQL() === $query->getDQL()) {
         $query = $this->lastQuery;
     }
     if ($this->lastQuery !== $query) {
         $this->lastResult = new ResultSet($query, $this, $repository);
     }
     return $this->lastQuery = $query;
 }
开发者ID:kdyby,项目名称:doctrine,代码行数:17,代码来源:QueryObject.php


示例19: setRowCount

 /**
  * Sets the total row count for this paginator
  *
  * Can be either an integer, or a Doctrine\ORM\Query object
  * which returns the count
  *
  * @param Query|integer $rowCount
  * @return void
  */
 public function setRowCount($rowCount)
 {
     if ($rowCount instanceof Query) {
         $this->rowCount = $rowCount->getSingleScalarResult();
     } else {
         if (is_integer($rowCount)) {
             $this->rowCount = $rowCount;
         } else {
             throw new \InvalidArgumentException("Invalid row count");
         }
     }
 }
开发者ID:protecinnovations,项目名称:DoctrineExtensions,代码行数:21,代码来源:PaginationAdapter.php


示例20: paginate

 public function paginate($page, Query $query, $itemsPerPage = 10)
 {
     if (!is_numeric($page)) {
         throw new \Exception('Valor no numerico para la paginacion');
     }
     $this->currentPage = (int) $page;
     $this->itemsPerPage = $itemsPerPage;
     $this->calLastPage(count($query->getResult()));
     $this->calRange();
     $query->setFirstResult($this->offset())->setMaxResults($this->itemsPerPage);
     return $query->getResult();
 }
开发者ID:rimitola8511,项目名称:PaginatorBundle,代码行数:12,代码来源:Paginator.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ORM\QueryBuilder类代码示例发布时间:2022-05-23
下一篇:
PHP ORM\PersistentCollection类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap