From 3d3312d47597249def3ed8efdcbf68869e3fef31 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 23 Dec 2011 15:07:03 -0500 Subject: Refs #4239 improved the documentation on ElggBatch for the limit option --- engine/classes/ElggBatch.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'engine/classes/ElggBatch.php') diff --git a/engine/classes/ElggBatch.php b/engine/classes/ElggBatch.php index 62128e34f..2a97f9ff5 100644 --- a/engine/classes/ElggBatch.php +++ b/engine/classes/ElggBatch.php @@ -92,7 +92,7 @@ class ElggBatch /** * Stop after this many results. * - * @var unknown_type + * @var int */ private $limit = 0; @@ -147,7 +147,9 @@ class ElggBatch * * @param string $getter The function used to get objects. Usually * an elgg_get_*() function, but can be any valid PHP callback. - * @param array $options The options array to pass to the getter function + * @param array $options The options array to pass to the getter function. If limit is + * not set, 10 is used as the default. In most cases that is not + * what you want. * @param mixed $callback An optional callback function that all results will be passed * to upon load. The callback needs to accept $result, $getter, * $options. @@ -319,13 +321,13 @@ class ElggBatch */ public function next() { // if we'll be at the end. - if ($this->processedResults + 1 >= $this->limit && $this->limit > 0) { + if (($this->processedResults + 1) >= $this->limit && $this->limit > 0) { $this->results = array(); return false; } // if we'll need new results. - if ($this->resultIndex + 1 >= $this->chunkSize) { + if (($this->resultIndex + 1) >= $this->chunkSize) { if (!$this->getNextResultsChunk()) { $this->results = array(); return false; @@ -356,4 +358,4 @@ class ElggBatch $key = key($this->results); return ($key !== NULL && $key !== FALSE); } -} \ No newline at end of file +} -- cgit v1.2.3