本文整理汇总了PHP中CacheHandler::fromResultSet方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheHandler::fromResultSet方法的具体用法?PHP CacheHandler::fromResultSet怎么用?PHP CacheHandler::fromResultSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheHandler
的用法示例。
在下文中一共展示了CacheHandler::fromResultSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Executes the query.
*
* @param string $params Any additional query parameters.
* @param integer $hydrationMode Processing mode to be used during the hydration process.
* @return mixed
*/
public function execute($params = array(), $hydrationMode = null)
{
if ($this->_em->getUnitOfWork()->hasPendingInsertions()) {
$this->_em->flush();
}
if ($hydrationMode !== null) {
$this->_hydrationMode = $hydrationMode;
}
$params = $this->getParams($params);
// Check result cache
if ($cacheDriver = $this->getResultCacheDriver()) {
// Calculate hash for DQL query.
$hash = md5($this->getDql() . var_export($params, true));
$cached = $this->_expireResultCache ? false : $cacheDriver->fetch($hash);
if ($cached === false) {
// Cache miss.
$result = $this->_doExecute($params);
$queryResult = CacheHandler::fromResultSet($this, $result);
$cacheDriver->save($hash, $queryResult->toCachedForm(), $this->_resultCacheTTL);
return $result;
} else {
// Cache hit.
$queryResult = CacheHandler::fromCachedResult($this, $cached);
return $queryResult->getResultSet();
}
}
$stmt = $this->_doExecute($params);
if (is_integer($stmt)) {
return $stmt;
}
return $this->_em->getHydrator($this->_hydrationMode)->hydrateAll($stmt, $this->_resultSetMapping);
}