Commit 814223bd authored by mahono's avatar mahono

* unified and simplified Hydrate->fetchOne() as well as Table->find()

* both always return reliable false if result is empty
parent 744666ab
...@@ -934,12 +934,13 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable ...@@ -934,12 +934,13 @@ class Doctrine_Hydrate extends Doctrine_Object implements Serializable
$collection = $this->execute($params, $hydrationMode); $collection = $this->execute($params, $hydrationMode);
if (count($collection) === 0) {
return false;
}
switch ($hydrationMode) { switch ($hydrationMode) {
case Doctrine::HYDRATE_RECORD: case Doctrine::HYDRATE_RECORD:
if (count($collection) > 0) {
return $collection->getFirst(); return $collection->getFirst();
}
break;
case Doctrine::HYDRATE_ARRAY: case Doctrine::HYDRATE_ARRAY:
return array_shift($collection); return array_shift($collection);
} }
......
...@@ -879,15 +879,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -879,15 +879,11 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
switch ($hydrationMode) { switch ($hydrationMode) {
case Doctrine::FETCH_RECORD: case Doctrine::FETCH_RECORD:
if (count($records) > 0) {
return $records->getFirst(); return $records->getFirst();
}
case Doctrine::FETCH_ARRAY: case Doctrine::FETCH_ARRAY:
if ( ! empty($records[0])) {
return array_shift($records); return array_shift($records);
} }
} }
}
return false; return false;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment