Statusdat/Query::fetchRow: Fix strict standards violation

This commit is contained in:
Eric Lippmann 2013-10-21 16:02:46 +02:00
parent 02de834522
commit 30b37aa1e5

View File

@ -29,6 +29,7 @@
namespace Icinga\Protocol\Statusdat; namespace Icinga\Protocol\Statusdat;
use Exception; use Exception;
use Icinga\Exception\ProgrammingError;
use Icinga\Filter\Query\Node; use Icinga\Filter\Query\Node;
use Icinga\Protocol; use Icinga\Protocol;
use Icinga\Data\BaseQuery; use Icinga\Data\BaseQuery;
@ -37,14 +38,13 @@ use Icinga\Protocol\Statusdat\Query\IQueryPart;
/** /**
* Base implementation for Statusdat queries. * Base implementation for Statusdat queries.
*
*/ */
class Query extends BaseQuery class Query extends BaseQuery
{ {
/** /**
* An array denoting valid targets by mapping the query target to * An array denoting valid targets by mapping the query target to
* the 'define' directives found in the status.dat/objects.cache files * the 'define' directives found in the status.dat/objects.cache files
* *
* @var array * @var array
*/ */
public static $VALID_TARGETS = array( public static $VALID_TARGETS = array(
@ -394,7 +394,7 @@ class Query extends BaseQuery
return $result; return $result;
} }
/** /**
* Apply all filters of this filterable on the datasource * Apply all filters of this filterable on the datasource
*/ */
@ -409,14 +409,15 @@ class Query extends BaseQuery
} }
/** /**
* Fetch the first result row * Return only the first row fetched from the result set
* *
* @return MonitoringObjectList The monitoring object matching this query * @return MonitoringObjectList The monitoring object matching this query
*/ */
public function fetchRow() public function fetchRow()
{ {
$result = $this->fetchAll(); $rs = $this->fetchAll();
return $result; $rs->rewind();
return $rs->current();
} }
/** /**
@ -461,13 +462,11 @@ class Query extends BaseQuery
} }
/** /**
* Fetch one result * Return the value of the first column for the first row fetched from the result set
*
* @return mixed
*/ */
public function fetchOne() public function fetchOne()
{ {
return next($this->fetchAll()); throw new ProgrammingError('Statusdat/Query::fetchOne not yet implemented');
} }
/** /**
@ -481,6 +480,4 @@ class Query extends BaseQuery
$q->limit(null, null); $q->limit(null, null);
return count($q->fetchAll()); return count($q->fetchAll());
} }
} }