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