From ad82b4ff98b096f8a66e3f4f91d1a628dd3ebb65 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 7 May 2013 15:36:21 -0400 Subject: [PATCH] throw exception if we get unexpected numbers of results in cc_pref --- airtime_mvc/application/models/Preference.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index f2eeee8a4..e96d4e888 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -38,7 +38,11 @@ class Application_Model_Preference $result = Application_Common_Database::prepareAndExecute($sql, $paramMap, 'column'); $paramMap = array(); - if ($result == 1) { + if ($result > 1) { + //this case should not happen. + throw new Exception("Invalid number of results returned. Should be ". + "0 or 1, but is '$result' instead"); + } elseif ($result == 1) { // result found if (is_null($id) || !$isUserValue) { // system pref @@ -80,7 +84,7 @@ class Application_Model_Preference } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); - Logging::info("Could not connect to database: ".$e->getMessage()); + Logging::info("Database error: ".$e->getMessage()); exit; }