DataView: Implement QueryInterface
An instance of DataView should implement the full interface, not only parts of it.
This commit is contained in:
parent
e04655e8cf
commit
3770741ba5
|
@ -3,14 +3,11 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\DataView;
|
||||
|
||||
use Countable;
|
||||
use Icinga\Data\QueryInterface;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Data\Filter\FilterMatch;
|
||||
use Icinga\Data\Browsable;
|
||||
use Icinga\Data\PivotTable;
|
||||
use Icinga\Data\Sortable;
|
||||
use Icinga\Data\ConnectionInterface;
|
||||
use Icinga\Data\Filterable;
|
||||
use Icinga\Exception\QueryException;
|
||||
use Icinga\Web\Request;
|
||||
use Icinga\Web\Url;
|
||||
|
@ -19,12 +16,12 @@ use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
|||
/**
|
||||
* A read-only view of an underlying query
|
||||
*/
|
||||
abstract class DataView implements Browsable, Countable, Filterable, Sortable
|
||||
abstract class DataView implements QueryInterface, IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* The query used to populate the view
|
||||
*
|
||||
* @var \Icinga\Data\SimpleQuery
|
||||
* @var QueryInterface
|
||||
*/
|
||||
protected $query;
|
||||
|
||||
|
@ -403,6 +400,114 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable
|
|||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->query);
|
||||
return $this->query->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a limit count and offset
|
||||
*
|
||||
* @param int $count Number of rows to return
|
||||
* @param int $offset Start returning after this many rows
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function limit($count = null, $offset = null)
|
||||
{
|
||||
$this->query->limit($count, $offset);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a limit is set
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLimit()
|
||||
{
|
||||
return $this->query->hasLimit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the limit if any
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getLimit()
|
||||
{
|
||||
return $this->query->getLimit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an offset is set
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOffset()
|
||||
{
|
||||
return $this->query->hasOffset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset if any
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getOffset()
|
||||
{
|
||||
return $this->query->hasOffset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an array containing all rows of the result set
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAll()
|
||||
{
|
||||
return $this->getQuery()->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the first row of the result set
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fetchRow()
|
||||
{
|
||||
return $this->getQuery()->fetchRow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a column of all rows of the result set as an array
|
||||
*
|
||||
* @param int $columnIndex Index of the column to fetch
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchColumn($columnIndex = 0)
|
||||
{
|
||||
return $this->getQuery()->fetchColumn($columnIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the first column of the first row of the result set
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetchOne()
|
||||
{
|
||||
return $this->getQuery()->fetchOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all rows of the result set as an array of key-value pairs
|
||||
*
|
||||
* The first column is the key, the second column is the value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchPairs()
|
||||
{
|
||||
return $this->getQuery()->fetchPairs();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue