mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-21 12:54:26 +02:00
Fetchable: Add method fetch() which returns an iterator
This commit is contained in:
parent
524c449649
commit
7a6837de0e
@ -3,11 +3,20 @@
|
||||
|
||||
namespace Icinga\Data;
|
||||
|
||||
use Iterator;
|
||||
|
||||
/**
|
||||
* Interface for retrieving data
|
||||
*/
|
||||
interface Fetchable
|
||||
{
|
||||
/**
|
||||
* Fetch and return all rows of the result set using an iterator
|
||||
*
|
||||
* @return Iterator
|
||||
*/
|
||||
public function fetch();
|
||||
|
||||
/**
|
||||
* Retrieve an array containing all rows of the result set
|
||||
*
|
||||
|
@ -4,6 +4,7 @@
|
||||
namespace Icinga\Data;
|
||||
|
||||
use ArrayIterator;
|
||||
use Iterator;
|
||||
use IteratorAggregate;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Exception\IcingaException;
|
||||
@ -103,11 +104,11 @@ class SimpleQuery implements QueryInterface, Queryable, IteratorAggregate
|
||||
/**
|
||||
* Return a iterable for this query's result
|
||||
*
|
||||
* @return ArrayIterator
|
||||
* @return Iterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->fetchAll());
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -351,6 +352,16 @@ class SimpleQuery implements QueryInterface, Queryable, IteratorAggregate
|
||||
return $this->limitOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and return all rows of the result set using an iterator
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function fetch()
|
||||
{
|
||||
return new ArrayIterator($this->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an array containing all rows of the result set
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace Icinga\Module\Monitoring\DataView;
|
||||
|
||||
use ArrayIterator;
|
||||
use Iterator;
|
||||
use IteratorAggregate;
|
||||
use Icinga\Data\QueryInterface;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
@ -61,11 +61,11 @@ abstract class DataView implements QueryInterface, IteratorAggregate
|
||||
/**
|
||||
* Return a iterator for all rows of the result set
|
||||
*
|
||||
* @return ArrayIterator
|
||||
* @return Iterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->fetchAll());
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -469,6 +469,16 @@ abstract class DataView implements QueryInterface, IteratorAggregate
|
||||
return $this->query->hasOffset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and return all rows of the result set using an iterator
|
||||
*
|
||||
* @return Iterator
|
||||
*/
|
||||
public function fetch()
|
||||
{
|
||||
return $this->getQuery()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an array containing all rows of the result set
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user