From 814223bd395054a882e997cb1913d08955235084 Mon Sep 17 00:00:00 2001 From: mahono Date: Thu, 6 Sep 2007 13:18:46 +0000 Subject: [PATCH] * unified and simplified Hydrate->fetchOne() as well as Table->find() * both always return reliable false if result is empty --- lib/Doctrine/Hydrate.php | 9 +++++---- lib/Doctrine/Table.php | 8 ++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index 3da0e626d..fe1e63af0 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -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); } diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index 6581f68f8..94db0cd85 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -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;