1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-06 06:07:39 +02:00

DibiResult::getIterator() - removed optional $offset and $limit parameters (BC break!)

This commit is contained in:
David Grudl
2010-08-03 16:59:31 +02:00
parent 792a25d57b
commit 019f6864cf
3 changed files with 8 additions and 38 deletions

View File

@@ -24,13 +24,6 @@
* unset($result);
* </code>
*
* Optionally you can specify offset and limit:
* <code>
* foreach ($result->getIterator(2, 3) as $row) {
* print_r($row);
* }
* </code>
*
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi
*/
@@ -39,12 +32,6 @@ class DibiResultIterator implements Iterator, Countable
/** @var DibiResult */
private $result;
/** @var int */
private $offset;
/** @var int */
private $limit;
/** @var int */
private $row;
@@ -54,14 +41,10 @@ class DibiResultIterator implements Iterator, Countable
/**
* @param DibiResult
* @param int offset
* @param int limit
*/
public function __construct(DibiResult $result, $offset = NULL, $limit = NULL)
public function __construct(DibiResult $result)
{
$this->result = $result;
$this->offset = (int) $offset;
$this->limit = $limit === NULL ? -1 : (int) $limit;
}
@@ -73,7 +56,7 @@ class DibiResultIterator implements Iterator, Countable
public function rewind()
{
$this->pointer = 0;
$this->result->seek($this->offset);
$this->result->seek(0);
$this->row = $this->result->fetch();
}
@@ -107,7 +90,6 @@ class DibiResultIterator implements Iterator, Countable
*/
public function next()
{
//$this->result->seek($this->offset + $this->pointer + 1);
$this->row = $this->result->fetch();
$this->pointer++;
}
@@ -120,7 +102,7 @@ class DibiResultIterator implements Iterator, Countable
*/
public function valid()
{
return !empty($this->row) && ($this->limit < 0 || $this->pointer < $this->limit);
return !empty($this->row);
}