本文整理汇总了PHP中Doctrine\ORM\Query::setHydrationMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::setHydrationMode方法的具体用法?PHP Query::setHydrationMode怎么用?PHP Query::setHydrationMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Query
的用法示例。
在下文中一共展示了Query::setHydrationMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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());
}
}
示例3: getQuery
/**
* @return Query
* @throws \LogicException If source of a query is not valid
*/
protected function getQuery()
{
if (null === $this->query) {
if ($this->source instanceof Query) {
$this->query = $this->cloneQuery($this->source);
} elseif ($this->source instanceof QueryBuilder) {
$this->query = $this->source->getQuery();
} else {
throw new \LogicException('Unexpected source');
}
unset($this->source);
// initialize cloned query
$this->maxResults = $this->query->getMaxResults();
if (!$this->maxResults || $this->requestedBufferSize < $this->maxResults) {
$this->query->setMaxResults($this->requestedBufferSize);
}
if (null !== $this->requestedHydrationMode) {
$this->query->setHydrationMode($this->requestedHydrationMode);
}
$this->firstResult = (int) $this->query->getFirstResult();
}
return $this->query;
}
示例4: setTranslatableHints
/**
* Loads all translations with all translatable
* fields from the given entity
*
* @link https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md#entity-domain-object
*
* @param Query $query
* @param string $locale
* @param string $result = {'array', 'object'}
* @param boolean $INNER_JOIN
* @param boolean $FALLBACK
* @param boolean $lazy_loading
*
* @return Query
* @access public
* @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
*/
public function setTranslatableHints(Query $query, $locale, $INNER_JOIN = false, $FALLBACK = true, $lazy_loading = true)
{
// BE CARFULL ::: Strange Issue with Query Hint and APC
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
// if you use memcache or apc. You should set locale and other options like fallbacks to query through hints. Otherwise the query will be cached with a first used locale
$query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE, $locale);
// take locale from session or request etc.
if ($INNER_JOIN) {
$query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_INNER_JOIN, $INNER_JOIN);
// will use INNER joins for translations instead of LEFT joins, so that in case if you do not want untranslated records in your result set for instance.
}
if (!$lazy_loading) {
// to avoid lazy-loading.
$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
}
$query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_FALLBACK, $FALLBACK);
// fallback to default values in case if record is not translated
// $config = $this->container->get('doctrine')->getManager()->getConfiguration();
// if ($config->getCustomHydrationMode(TranslationWalker::HYDRATE_OBJECT_TRANSLATION) === null) {
// $config->addCustomHydrationMode(
// TranslationWalker::HYDRATE_OBJECT_TRANSLATION,
// 'Gedmo\\Translatable\\Hydrator\\ORM\\ObjectHydrator'
// );
// }
$query->setHydrationMode(\Gedmo\Translatable\Query\TreeWalker\TranslationWalker::HYDRATE_OBJECT_TRANSLATION);
$query->setHint(Query::HINT_REFRESH, true);
return $query;
}