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
$collection = $this->execute($params, $hydrationMode);
if (count($collection) === 0) {
return false;
}
switch ($hydrationMode) {
case Doctrine::HYDRATE_RECORD:
if (count($collection) > 0) {
return $collection->getFirst();
}
break;
return $collection->getFirst();
case Doctrine::HYDRATE_ARRAY:
return array_shift($collection);
}
......
......@@ -879,13 +879,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
switch ($hydrationMode) {
case Doctrine::FETCH_RECORD:
if (count($records) > 0) {
return $records->getFirst();
}
return $records->getFirst();
case Doctrine::FETCH_ARRAY:
if ( ! empty($records[0])) {
return array_shift($records);
}
return array_shift($records);
}
}
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