From b774c987770d263bc6c6b6431352e9590c375031 Mon Sep 17 00:00:00 2001 From: zYne Date: Mon, 28 May 2007 15:13:11 +0000 Subject: [PATCH] --- lib/Doctrine/Hydrate.php | 2 +- tests/Query/CacheTestCase.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index 5a213cdeb..829e0b33f 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -640,7 +640,7 @@ class Doctrine_Hydrate implements Serializable if ($this->_cache) { $dql = $this->getDql(); // calculate hash for dql query - $hash = strlen($dql) . md5($dql); + $hash = strlen($dql) . md5($dql . var_export($params, true)); $cached = $this->_cache->fetch($hash); diff --git a/tests/Query/CacheTestCase.php b/tests/Query/CacheTestCase.php index d0a566986..fee6d3674 100644 --- a/tests/Query/CacheTestCase.php +++ b/tests/Query/CacheTestCase.php @@ -70,5 +70,25 @@ class Doctrine_Query_Cache_TestCase extends Doctrine_UnitTestCase $this->assertTrue($coll instanceof Doctrine_Collection); $this->assertEqual($coll->count(), 8); } + public function testResultSetCacheSupportsPreparedStatements() + { + $q = new Doctrine_Query(); + $cache = new Doctrine_Cache_Array(); + $q->setCache($cache); + $q->select('u.name')->from('User u')->leftJoin('u.Phonenumber p') + ->where('u.id = ?'); + + $coll = $q->execute(array(5)); + + $this->assertEqual($cache->count(), 1); + $this->assertTrue($coll instanceof Doctrine_Collection); + $this->assertEqual($coll->count(), 1); + + $coll = $q->execute(array(5)); + + $this->assertEqual($cache->count(), 1); + $this->assertTrue($coll instanceof Doctrine_Collection); + $this->assertEqual($coll->count(), 1); + } }