From: Jan Schneider Date: Sun, 30 Aug 2009 10:25:46 +0000 (+0200) Subject: Safer Countable implementation, but requires one more query per list. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f9306660750871faf8a404f6c5d92d81ca438947;p=horde.git Safer Countable implementation, but requires one more query per list. --- diff --git a/framework/Rdo/lib/Horde/Rdo/List.php b/framework/Rdo/lib/Horde/Rdo/List.php index 212878ee1..013cf76e8 100644 --- a/framework/Rdo/lib/Horde/Rdo/List.php +++ b/framework/Rdo/lib/Horde/Rdo/List.php @@ -12,7 +12,7 @@ * @category Horde * @package Horde_Rdo */ -class Horde_Rdo_List implements Iterator +class Horde_Rdo_List implements Iterator, Countable { /** * Rdo Mapper @@ -57,6 +57,12 @@ class Horde_Rdo_List implements Iterator protected $_eof; /** + * The number of objects in the list. + * @var integer + */ + protected $_count; + + /** * Constructor. * * @param mixed $query The query to run when results are @@ -91,6 +97,8 @@ class Horde_Rdo_List implements Iterator // Keep a handle on the Mapper object for running the query. $this->_mapper = $mapper; + + $this->_count = $this->_mapper->count($query); } /** @@ -190,4 +198,9 @@ class Horde_Rdo_List implements Iterator return !$this->_eof; } + public function count() + { + return $this->_count; + } + }