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


PHP Query::getResult方法代码示例

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


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

示例1: paginateQuery

 public function paginateQuery(Query $query, Search $search)
 {
     $results = $query->getResult();
     $limit = $search->getListAll() ? count($results) ? count($results) : 1 : $search->getMaxPerPage();
     $adapter = new DoctrineORMAdapter($query);
     $paginator = new Pagerfanta($adapter);
     $paginator->setMaxPerPage($limit);
     $paginator->setCurrentPage($search->getPage());
     $paginator->getCurrentPageResults();
     // Just to cache the consult
     $paginator->getNbResults();
     // Just to cache the results
     return $paginator;
 }
开发者ID:code-community,项目名称:search,代码行数:14,代码来源:SearchAware.php

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

示例3: load

 /**
  * Loads the collection into memory.
  *
  * @return void
  */
 private function load()
 {
     if (!$this->isLoaded) {
         $this->elements = $this->query->getResult();
         $this->isLoaded = true;
     }
 }
开发者ID:e-ruiz,项目名称:brick,代码行数:12,代码来源:QueryCollection.php

示例4: execute

 /**
  * Executes query and saving query SQL to list (if needed)
  *
  * @access   public
  * @param    boolean $noResults returns no results, if TRUE
  * @return   array
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function execute($noResults = FALSE)
 {
     if (!$noResults) {
         static::$mResult = $this->oQuery->getResult();
     } else {
         static::$mResult = $this->oQuery->execute();
     }
     return static::$mResult;
 }
开发者ID:ktrzos,项目名称:plethora,代码行数:18,代码来源:DB.php

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

示例6: paginate

 /**
  * {@inheritdoc}
  */
 public function paginate(Query $query, $results, $offset, $arrayResult = true)
 {
     if ($results <= 0 || $results > $this->maxResults) {
         $results = $this->defaultResults;
     }
     if ($offset < 0) {
         $offset = 0;
     }
     $paginator = new Paginator($query, false);
     $query->setFirstResult($offset)->setMaxResults($results);
     if ($arrayResult) {
         $result = $query->getArrayResult();
     } else {
         $result = $query->getResult();
     }
     return ['recordsTotal' => count($paginator), 'recordsFiltered' => count($paginator), 'data' => $result];
 }
开发者ID:mangati,项目名称:base-bundle,代码行数:20,代码来源:DataTables.php

示例7: getIterator

 /**
  * @param int|null
  * @return \ArrayIterator
  */
 public function getIterator($hydrationMode = NULL)
 {
     if ($this->iterator !== NULL) {
         return $this->iterator;
     }
     if ($hydrationMode !== NULL) {
         $this->query->setHydrationMode($hydrationMode);
     }
     $this->frozen = TRUE;
     if ($this->fetchJoinCollection && ($this->query->getMaxResults() > 0 || $this->query->getFirstResult() > 0)) {
         $this->iterator = $this->createPaginatedQuery($this->query)->getIterator();
     } else {
         $this->iterator = new \ArrayIterator($this->query->getResult(NULL));
     }
     if ($this->repository && $this->queryObject) {
         $this->queryObject->queryFetched($this->repository, $this->iterator);
     }
     return $this->iterator;
 }
开发者ID:librette,项目名称:doctrine-queries,代码行数:23,代码来源:ResultSet.php

示例8: getIterator

 /**
  * @param int $hydrationMode
  * @throws QueryException
  * @return \ArrayIterator
  */
 public function getIterator($hydrationMode = ORM\AbstractQuery::HYDRATE_OBJECT)
 {
     if ($this->iterator !== NULL) {
         return $this->iterator;
     }
     $this->query->setHydrationMode($hydrationMode);
     try {
         $this->frozen = TRUE;
         if ($this->fetchJoinCollection && ($this->query->getMaxResults() > 0 || $this->query->getFirstResult() > 0)) {
             $this->iterator = $this->createPaginatedQuery($this->query)->getIterator();
         } else {
             $this->iterator = new \ArrayIterator($this->query->getResult(NULL));
         }
         if ($this->queryObject !== NULL && $this->repository !== NULL) {
             $this->queryObject->postFetch($this->repository, $this->iterator);
         }
         return $this->iterator;
     } catch (ORMException $e) {
         throw new QueryException($e, $this->query, $e->getMessage());
     }
 }
开发者ID:kdyby,项目名称:doctrine,代码行数:26,代码来源:ResultSet.php

示例9: _authenticateQueryDql

 /**
  * Get result identities
  *
  * @param \Doctrine\ORM\Query $dqlQuery
  * @return array
  * @throws \Zend_Auth_Adapter_Exception
  */
 protected function _authenticateQueryDql(\Doctrine\ORM\Query $dqlQuery)
 {
     try {
         $resultIdentities = $dqlQuery->getResult();
     } catch (\Exception $e) {
         throw new \Zend_Auth_Adapter_Exception('The supplied parameters to Extlib\\Auth\\Adapter\\Doctrine2 failed to ' . 'produce a valid sql statement, please check table and column names ' . 'for validity.', 0, $e);
     }
     return $resultIdentities;
 }
开发者ID:lciolecki,项目名称:zf-extensions-library,代码行数:16,代码来源:Doctrine2.php

示例10: retrieveCollectionResult

 /**
  * Performs a given database selection and post-processed the results.
  *
  * @param Doctrine\ORM\Query $query       The Query instance to be executed.
  * @param string             $orderBy     The order-by clause to use when retrieving the collection (optional) (default='').
  * @param boolean            $isPaginated Whether the given query uses a paginator or not (optional) (default=false).
  *
  * @return Array with retrieved collection.
  */
 public function retrieveCollectionResult(Query $query, $orderBy = '', $isPaginated = false)
 {
     $result = $query->getResult();
     if ($orderBy == 'RAND()') {
         // each entry in $result looks like array(0 => actualRecord, 'randomIdentifiers' => randomId)
         $resRaw = array();
         foreach ($result as $resultRow) {
             $resRaw[] = $resultRow[0];
         }
         $result = $resRaw;
     }
     return $result;
 }
开发者ID:robbrandt,项目名称:MUVideo,代码行数:22,代码来源:Movie.php

示例11: getCachedResult

 /**
  *
  * @param Query $query        	
  * @param string $cacheItemKey        	
  * @return array|bool|mixed|string
  */
 protected function getCachedResult(Query $query, $cacheItemKey = '', $ttl = 0)
 {
     if (!$cacheItemKey) {
         $cacheItemKey = ($this->cache_prefix ? $this->cache_prefix : get_called_class()) . md5($query->getDQL());
     }
     $cache = $this->getEntityManager()->getConfiguration()->getResultCacheImpl();
     // test if item exists in the cache
     if ($cache->contains($cacheItemKey)) {
         // retrieve item from cache
         $items = $cache->fetch($cacheItemKey);
     } else {
         // retrieve item from repository
         $items = $query->getResult();
         // save item to cache
         $cache->save($cacheItemKey, $items, $ttl);
     }
     return $items;
 }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:24,代码来源:Paginator.php

示例12: loadQuery

 private function loadQuery()
 {
     if ($this->result === null) {
         $this->result = $this->query->getResult();
     }
 }
开发者ID:stof,项目名称:porpaginas,代码行数:6,代码来源:ORMQueryResult.php

示例13: newAction

        /**
     * @route: blog_new
     * Tag Controller
     */
    public function newAction()
    {
        // entity manager and query builder objects
        $em = $this->getEm();


        $query = new Query($em);
        $query->setDQL(
            'SELECT p,comments
                FROM Bundle\BlogBundle\Entity\Post p
                JOIN p.comments comments
                ORDER BY p.date DESC'
        );
        $query->setMaxResults(1);
        //$query->setParameter(1, $slug);
        $posts = $query->getResult();


        return $this->render('BlogBundle:Blog:post.html.twig', array(
            'post' => $posts[0]
        ));
    }
开发者ID:rdbsf,项目名称:BlogBundle,代码行数:26,代码来源:BlogController.php

示例14: populateSelectFromDatabaseQuery

 /**
  * Populate a Zend_Form SELECT element from a database table
  *
  * @param \Doctrine\ORM\Query $query The query to for the database select
  * @param Zend_Form_Element_Select $element The form element to populate
  * @param string $entity The Doctrine2 entity class to select items from
  * @param string $indexElement The element with which to set the select value attributes with (typically `id`)
  * @param string|array $displayElements If a string, then the database column element to show in the select
  *         dropdown. If an array, the contents of these elements will be concatenated with dashes
  * @param string $orderBy The element to order by
  * @param string $orderDir The order direction
  * @return int The maximum value of the $indexElement (asuming integer!)
  */
 public static function populateSelectFromDatabaseQuery($query, $element, $entity, $indexElement, $displayElements, $orderBy = null, $orderDir = 'ASC')
 {
     if (!is_array($displayElements)) {
         $displayElements = [$displayElements];
     }
     $rows = $query->getResult();
     $options = array('0' => '');
     $maxId = 0;
     foreach ($rows as $r) {
         $text = '';
         foreach ($displayElements as $idx => $de) {
             if (is_array($de)) {
                 switch ($de['type']) {
                     case 'STRING':
                         $str = $r[$idx];
                         break;
                     case 'DATE':
                     case 'TIME':
                     case 'DATETIME':
                         $str = $r[$idx]->format($de['format']);
                         break;
                     default:
                         die('Unhandled type in OSS/Form/Trait/Doctrine2::populateSelectFromDatabaseQuery()');
                 }
             } else {
                 $str = $r[$de];
             }
             $text .= "{$str} - ";
         }
         $text = substr($text, 0, strlen($text) - 3);
         $options[$r[$indexElement]] = $text;
         if ($r[$indexElement] > $maxId) {
             $maxId = $r[$indexElement];
         }
     }
     $element->setMultiOptions($options);
     return $maxId;
 }
开发者ID:opensolutions,项目名称:oss-framework,代码行数:51,代码来源:Doctrine2.php

示例15: retrieveCollectionResult

 /**
  * Performs a given database selection and post-processed the results.
  *
  * @param Doctrine\ORM\Query $query       The Query instance to be executed.
  * @param string             $orderBy     The order-by clause to use when retrieving the collection (optional) (default='').
  * @param boolean            $isPaginated Whether the given query uses a paginator or not (optional) (default=false).
  *
  * @return Array with retrieved collection and (for paginated queries) the amount of total records affected.
  */
 public function retrieveCollectionResult(Query $query, $orderBy = '', $isPaginated = false)
 {
     if (!$isPaginated) {
         $result = $query->getResult();
     } else {
         $paginator = new Paginator($query, false);
         $count = count($paginator);
         $result = $paginator;
     }
     if (!$isPaginated) {
         return $result;
     } else {
         return array($result, $count);
     }
 }
开发者ID:Silwereth,项目名称:core,代码行数:24,代码来源:Route.php


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