From 5b594a546895bb16b462109a57ac2e8c9972c4c4 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 31 Jan 2007 23:00:43 +0000 Subject: [PATCH] some methods added --- lib/Doctrine/Cache.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/Cache.php b/lib/Doctrine/Cache.php index a0eb98456..d7202ec51 100644 --- a/lib/Doctrine/Cache.php +++ b/lib/Doctrine/Cache.php @@ -93,14 +93,33 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite { return array_pop($this->_queries); } + /** + * reset + * + * removes all queries from the query stack + * @return void + */ + public function reset() + { + $this->_queries = array(); + } /** * count * - * @return integer the number of queries in the stack + * @return integer the number of queries in the stack */ public function count() { - return count($this->_queries); + return count($this->_queries); + } + /** + * getIterator + * + * @return ArrayIterator an iterator that iterates through the query stack + */ + public function getIterator() + { + return new ArrayIterator($this->_queries); } /** * save @@ -151,7 +170,7 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite } public function onQuery(Doctrine_Db_Event $event) { - $this->addQuery($event->getQuery(), $event->getInvoker()->getName()); + $this->add($event->getQuery(), $event->getInvoker()->getName()); } public function onPrePrepare(Doctrine_Db_Event $event) @@ -178,6 +197,6 @@ class Doctrine_Cache extends Doctrine_Db_EventListener implements Countable, Ite } public function onExecute(Doctrine_Db_Event $event) { - $this->addQuery($event->getQuery(), $event->getInvoker()->getName()); + $this->add($event->getQuery(), $event->getInvoker()->getName()); } }