/** * Executes the query and returns an IterableResult that can be used to incrementally * iterate over the result. * * @param ArrayCollection|array|null $parameters The query parameters. * @param integer|null $hydrationMode The hydration mode to use. * * @return \Doctrine\ORM\Internal\Hydration\IterableResult */ public function iterate($parameters = null, $hydrationMode = null) { if ($hydrationMode !== null) { $this->setHydrationMode($hydrationMode); } if (!empty($parameters)) { $this->setParameters($parameters); } $rsm = $this->getResultSetMapping(); $stmt = $this->_doExecute(); return $this->_em->newHydrator($this->_hydrationMode)->iterate($stmt, $rsm, $this->_hints); }
/** * Execute query ignoring second level cache. * * @param ArrayCollection|array|null $parameters * @param integer|null $hydrationMode * * @return mixed */ private function executeIgnoreQueryCache($parameters = null, $hydrationMode = null) { if ($hydrationMode !== null) { $this->setHydrationMode($hydrationMode); } if (!empty($parameters)) { $this->setParameters($parameters); } $setCacheEntry = function () { }; if ($this->_hydrationCacheProfile !== null) { list($cacheKey, $realCacheKey) = $this->getHydrationCacheId(); $queryCacheProfile = $this->getHydrationCacheProfile(); $cache = $queryCacheProfile->getResultCacheDriver(); $result = $cache->fetch($cacheKey); if (isset($result[$realCacheKey])) { return $result[$realCacheKey]; } if (!$result) { $result = array(); } $setCacheEntry = function ($data) use($cache, $result, $cacheKey, $realCacheKey, $queryCacheProfile) { $result[$realCacheKey] = $data; $cache->save($cacheKey, $result, $queryCacheProfile->getLifetime()); }; } $stmt = $this->_doExecute(); if (is_numeric($stmt)) { $setCacheEntry($stmt); return $stmt; } $rsm = $this->getResultSetMapping(); $data = $this->_em->newHydrator($this->_hydrationMode)->hydrateAll($stmt, $rsm, $this->_hints); $setCacheEntry($data); return $data; }
/** * Hydrates a collection from a given DBAL statement. * * @param array $assoc * @param \Doctrine\DBAL\Statement $stmt * @param PersistentCollection $coll * * @return array */ private function loadCollectionFromStatement($assoc, $stmt, $coll) { $rsm = $this->currentPersisterContext->rsm; $hints = array(UnitOfWork::HINT_DEFEREAGERLOAD => true, 'collection' => $coll); if (isset($assoc['indexBy'])) { $rsm = clone $this->currentPersisterContext->rsm; // this is necessary because the "default rsm" should be changed. $rsm->addIndexBy('r', $assoc['indexBy']); } return $this->em->newHydrator(Query::HYDRATE_OBJECT)->hydrateAll($stmt, $rsm, $hints); }
/** * {@inheritdoc} */ public function newHydrator($hydrationMode) { return $this->wrapped->newHydrator($hydrationMode); }
/** * Initializes a new instance of a class derived from <tt>AbstractHydrator</tt>. * * @param EntityManagerInterface $em The EntityManager to use. */ public function __construct(EntityManagerInterface $em) { $this->em = $em; $this->wrapped = $em->newHydrator($this->type); }