public function browseBandsByLocation($country, $state, $city, $region, $searchType, $currentPage, $pagingAmount, $dbConnection = null) { $bandSearchResults = null; $bandSkeletons = null; $countryID = null; $stateID = null; $cityID = null; $regionID = null; try { $bandParameters = new SearchParameters(); $bandParameters->setVariable(SearchConstants::CURRENT_PAGE_ID, $currentPage); $bandParameters->setVariable(SearchConstants::PAGING_AMOUNT_ID, $pagingAmount); //These elements are common to both search types $countryID = SearchUtilities::processSelectValues($country, 'defaultValue', '0'); if ($countryID != null) { $stateID = SearchUtilities::processSelectValues($state, 'defaultValue', '0'); } if ($stateID != null) { $cityID = SearchUtilities::processSelectValues($city, 'defaultValue', '0'); } if ($cityID != null) { $regionID = SearchUtilities::processSelectValues($region, 'defaultValue', '0'); } $bandParameters->setVariable(LocationConstants::LOCATION_COUNTRY_INPUT_ID, $countryID); $bandParameters->setVariable(LocationConstants::LOCATION_STATE_INPUT_ID, $stateID); $bandParameters->setVariable(LocationConstants::LOCATION_CITY_INPUT_ID, $cityID); $bandParameters->setVariable(LocationConstants::LOCATION_REGION_INPUT_ID, $regionID); $bandCount = BandSearchDao::getBandSearchCount($bandParameters, $dbConnection); $bandSkeletons = BandSearchDao::searchBands($bandParameters, $dbConnection); $bandSearchResults = new SearchResults(); $bandSearchResults->setVariable(SearchResults::SEARCH_PARAMETERS, $bandParameters); $bandSearchResults->setVariable(SearchResults::SKELETONS, $bandSkeletons); $bandSearchResults->setVariable(SearchResults::COUNT, $bandCount); $bandSearchResults->setVariable(SearchResults::PAGE_COUNT, ceil($bandCount / $pagingAmount)); } catch (Exception $ex) { $bandSearchResults = null; echo 'Caught exception: ', $ex->getMessage(), "\n"; } return $bandSearchResults; }