本文整理匯總了PHP中Doctrine\ORM\EntityManager::newHydrator方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityManager::newHydrator方法的具體用法?PHP EntityManager::newHydrator怎麽用?PHP EntityManager::newHydrator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\EntityManager
的用法示例。
在下文中一共展示了EntityManager::newHydrator方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
/**
* 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->newHydrator($this->_hydrationMode)->hydrateAll($stmt, $this->_resultSetMapping, $this->_hints);
$setCacheEntry($data);
return $data;
}
示例2: newHydrator
/**
* {@inheritDoc}
*/
public function newHydrator($hydrationMode)
{
switch ($hydrationMode) {
case Query::HYDRATE_OBJECT:
return new ObjectsToCollectionHydrator($this);
case Query::HYDRATE_SIMPLEOBJECT:
return new SimpleObjectsToCollectionHydrator($this);
}
return parent::newHydrator($hydrationMode);
}
示例3: iterate
/**
* 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);
}
$stmt = $this->_doExecute();
return $this->_em->newHydrator($this->_hydrationMode)->iterate($stmt, $this->_resultSetMapping, $this->_hints);
}
示例4: newHydrator
/**
* {@inheritdoc}
*/
public function newHydrator($hydrationMode)
{
$hydrators = $this->getLoggingHydrators();
if (isset($hydrators[$hydrationMode])) {
$className = $hydrators[$hydrationMode]['loggingClass'];
if (class_exists($className)) {
return new $className($this);
}
}
return parent::newHydrator($hydrationMode);
}
示例5: newHydrator
/**
* {@inheritDoc}
*/
public function newHydrator($hydrationMode)
{
switch ($hydrationMode) {
case Query::HYDRATE_OBJECT:
return new LoggingObjectHydrator($this);
case Query::HYDRATE_ARRAY:
return new LoggingArrayHydrator($this);
case Query::HYDRATE_SCALAR:
return new LoggingScalarHydrator($this);
case Query::HYDRATE_SINGLE_SCALAR:
return new LoggingSingleScalarHydrator($this);
case Query::HYDRATE_SIMPLEOBJECT:
return new LoggingSimpleObjectHydrator($this);
default:
return parent::newHydrator($hydrationMode);
}
}
示例6: loadCollectionFromStatement
/**
* Hydrate a collection from a given dbal statement.
*
* @param array $assoc
* @param Doctrine\DBAL\Statement $stmt
* @param PersistentCollection $coll
*/
private function loadCollectionFromStatement($assoc, $stmt, $coll)
{
$hints = array('deferEagerLoads' => true, 'collection' => $coll);
if (isset($assoc['indexBy'])) {
$rsm = clone $this->_rsm;
// this is necessary because the "default rsm" should be changed.
$rsm->addIndexBy('r', $assoc['indexBy']);
} else {
$rsm = $this->_rsm;
}
$hydrator = $this->_em->newHydrator(Query::HYDRATE_OBJECT);
$hydrator->hydrateAll($stmt, $rsm, $hints);
}
示例7: loadCollectionFromStatement
/**
* 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->rsm;
$hints = array(
UnitOfWork::HINT_DEFEREAGERLOAD => true,
'collection' => $coll
);
if (isset($assoc['indexBy'])) {
$rsm = clone ($this->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);
}
示例8: newHydrator
/**
* @param int $hydrationMode
* @return Doctrine\ORM\Internal\Hydration\AbstractHydrator|Hydration\ObjectHydrator|Hydration\SimpleObjectHydrator
* @throws \Doctrine\ORM\ORMException
*/
public function newHydrator($hydrationMode)
{
switch ($hydrationMode) {
case Query::HYDRATE_OBJECT:
return new Hydration\ObjectHydrator($this);
case Query::HYDRATE_SIMPLEOBJECT:
return new Hydration\SimpleObjectHydrator($this);
case Hydration\HashHydrator::NAME:
return new Hydration\HashHydrator($this);
default:
return parent::newHydrator($hydrationMode);
}
}
示例9: newHydrator
/**
* @param int $hydrationMode
* @return Doctrine\ORM\Internal\Hydration\AbstractHydrator
* @throws \Doctrine\ORM\ORMException
*/
public function newHydrator($hydrationMode)
{
switch ($hydrationMode) {
case Hydration\HashHydrator::NAME:
return new Hydration\HashHydrator($this);
default:
return parent::newHydrator($hydrationMode);
}
}
示例10: newHydrator
/**
* {@inheritDoc}
*
* @static
*/
public static function newHydrator($hydrationMode)
{
return \Doctrine\ORM\EntityManager::newHydrator($hydrationMode);
}
示例11: newHydrator
/**
* {@inheritdoc}
*/
public function newHydrator($hydrationMode)
{
return $this->wrapped->newHydrator($hydrationMode);
}