From aff4d5e33f0f70a49a1e1a69bb5e5c26ae4f6b9c Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sun, 1 Nov 2009 10:57:49 -0500 Subject: [PATCH] Don't include empty image_locations in the query results, log query. --- ansel/lib/Storage.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ansel/lib/Storage.php b/ansel/lib/Storage.php index bf9519ded..6a4154f8a 100644 --- a/ansel/lib/Storage.php +++ b/ansel/lib/Storage.php @@ -1040,8 +1040,11 @@ class Ansel_Storage */ public function searchLocations($search = '') { - $sql = 'SELECT DISTINCT image_location, image_latitude, image_longitude' - . ' FROM ansel_images WHERE image_location LIKE "' . $search . '%"'; + $sql = 'SELECT DISTINCT image_location, image_latitude, image_longitude FROM ansel_images WHERE LENGTH(image_location) > 0'; + if (strlen($search)) { + $sql .= ' AND image_location LIKE "' . $search . '%"'; + } + Horde::logMessage(sprintf("SQL QUERY BY Ansel_Storage::searchLocations: %s", $sql), __FILE__, __LINE__, PEAR_LOG_DEBUG); $results = $this->_db->query($sql); if ($results instanceof PEAR_Error) { throw new Horde_Exception($results->getMessage()); -- 2.11.0