RepositoryQuery: Properly handle queries returning no results

refs #8826
This commit is contained in:
Johannes Meyer 2015-05-20 09:11:46 +02:00
parent fb07f0b94c
commit a3d5cfc28a
1 changed files with 5 additions and 5 deletions

View File

@ -385,7 +385,7 @@ class RepositoryQuery implements QueryInterface, Iterator
} }
$result = $this->query->fetchOne(); $result = $this->query->fetchOne();
if ($this->repository->providesValueConversion()) { if ($result !== false && $this->repository->providesValueConversion()) {
$columns = $this->getColumns(); $columns = $this->getColumns();
$column = isset($columns[0]) ? $columns[0] : key($columns); $column = isset($columns[0]) ? $columns[0] : key($columns);
return $this->repository->retrieveColumn($column, $result); return $this->repository->retrieveColumn($column, $result);
@ -406,7 +406,7 @@ class RepositoryQuery implements QueryInterface, Iterator
} }
$result = $this->query->fetchRow(); $result = $this->query->fetchRow();
if ($this->repository->providesValueConversion()) { if ($result !== false && $this->repository->providesValueConversion()) {
foreach ($this->getColumns() as $alias => $column) { foreach ($this->getColumns() as $alias => $column) {
if (! is_string($alias)) { if (! is_string($alias)) {
$alias = $column; $alias = $column;
@ -431,7 +431,7 @@ class RepositoryQuery implements QueryInterface, Iterator
} }
$results = $this->query->fetchColumn(); $results = $this->query->fetchColumn();
if ($this->repository->providesValueConversion()) { if ($results !== false && $this->repository->providesValueConversion()) {
$columns = $this->getColumns(); $columns = $this->getColumns();
$aliases = array_keys($columns); $aliases = array_keys($columns);
$column = is_int($aliases[0]) ? $columns[0] : $aliases[0]; $column = is_int($aliases[0]) ? $columns[0] : $aliases[0];
@ -457,7 +457,7 @@ class RepositoryQuery implements QueryInterface, Iterator
} }
$results = $this->query->fetchPairs(); $results = $this->query->fetchPairs();
if ($this->repository->providesValueConversion()) { if (! empty($results) && $this->repository->providesValueConversion()) {
$columns = $this->getColumns(); $columns = $this->getColumns();
$aliases = array_keys($columns); $aliases = array_keys($columns);
$newResults = array(); $newResults = array();
@ -486,7 +486,7 @@ class RepositoryQuery implements QueryInterface, Iterator
} }
$results = $this->query->fetchAll(); $results = $this->query->fetchAll();
if ($this->repository->providesValueConversion()) { if (! empty($results) && $this->repository->providesValueConversion()) {
$columns = $this->getColumns(); $columns = $this->getColumns();
foreach ($results as $row) { foreach ($results as $row) {
foreach ($columns as $alias => $column) { foreach ($columns as $alias => $column) {