This method caches the hydrator instances which is used for all queries that don't
selectively iterate over the result.
public getHydrator ( integer $hydrationMode ) : Doctrine\ORM\Internal\Hydration\AbstractHydrator | ||
$hydrationMode | integer | |
return | Doctrine\ORM\Internal\Hydration\AbstractHydrator |
/** * Executes the query. * * @param ArrayCollection|array|null $parameters Query parameters. * @param integer|null $hydrationMode Processing mode to be used during the hydration process. * * @return mixed */ public function execute($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; } $data = $this->_em->getHydrator($this->_hydrationMode)->hydrateAll($stmt, $this->_resultSetMapping, $this->_hints); $setCacheEntry($data); return $data; }
/** * {@inheritDoc} * * @static */ public static function getHydrator($hydrationMode) { return \Doctrine\ORM\EntityManager::getHydrator($hydrationMode); }
/** * {@inheritdoc} */ public function getHydrator($hydrationMode) { return $this->wrapped->getHydrator($hydrationMode); }