Commit 2973b274 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 0b819a29
......@@ -125,6 +125,8 @@ class Doctrine_Hydrate implements Serializable
* @see Doctrine_Query::* constants
*/
protected $type = self::SELECT;
protected $_cache;
protected $_tableAliases = array();
/**
......@@ -150,6 +152,14 @@ class Doctrine_Hydrate implements Serializable
{
return $this->getQuery();
}
public function setCache(Doctrine_Cache_Interface $cache)
{
$this->_cache = $cache;
}
public function getCache()
{
return $this->_cache;
}
/**
* serialize
* this method is automatically called when this Doctrine_Hydrate is serialized
......@@ -627,12 +637,12 @@ class Doctrine_Hydrate implements Serializable
*/
public function execute($params = array(), $return = Doctrine::FETCH_RECORD)
{
if ($this->_options['resultSetCache']) {
if ($this->_cache) {
$dql = $this->getDql();
// calculate hash for dql query
$hash = strlen($dql) . md5($dql);
$cached = $this->_options['resultSetCache']->fetch($hash);
$cached = $this->_cache->fetch($hash);
if ($cached === null) {
// cache miss
......@@ -640,7 +650,7 @@ class Doctrine_Hydrate implements Serializable
$cached = $this->getCachedForm($array);
$this->_options['resultSetCache']->save($hash, $cached);
$this->_cache->save($hash, $cached);
} else {
$cached = unserialize($cached);
$this->_tableAliases = $cached[2];
......
......@@ -247,7 +247,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
}
// check for cache
if ( ! $this->_options['resultSetCache'] && ! $this->_options['parserCache']) {
if ( ! $this->_options['resultSetCache']) {
$parser = $this->getParser($queryPartName);
$sql = $parser->parse($queryPart);
......@@ -619,21 +619,10 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
public function getQuery($params = array())
{
// check if parser cache is on
if ($this->_options['resultSetCache'] !== false) {
/**
$dql = $this->getDql();
// calculate hash for dql query
$hash = strlen($dql) . md5($dql);
// check if cache has sql equivalent for given hash
$sql = $this->_options['parserCache']->fetch($hash, true);
if ($sql !== null) {
return $sql;
}
*/
// cache miss, build sql query from dql parts
if ($this->_cache) {
foreach ($this->_dqlParts as $queryPartName => $queryParts) {
if (is_array($queryParts) && ! empty($queryParts)) {
foreach ($queryParts as $queryPart) {
$this->getParser($queryPartName)->parse($queryPart);
}
......@@ -721,10 +710,6 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
array_shift($this->parts['where']);
}
// append sql query into cache
if ($this->_options['parserCache'] !== false) {
$this->_options['parserCache']->save($hash, $q);
}
return $q;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment