public function getBandGenres($bandID, $dbConnection = null) { $bandGenres = null; try { $bandGenres = BandGenreDao::selectBandGenres($bandID, $dbConnection); } catch (Exception $ex) { $bandGenres = null; } return $bandGenres; }
public function searchBands($searchParameters, $dbConnection = null) { $bandList = null; $preparedStatement = null; try { $bandSearchQuery = null; $bandIDQuery = null; if ($dbConnection == null) { $dbConnection = DatabaseUtilities::getDatabaseConnection(); } $bandIDQuery = "SELECT DISTINCT B.BAND_ID FROM band B WHERE 1 = 1"; $bandIDQuery .= BandSearchDao::getBandSearchWhereClause($searchParameters); $bandSearchQuery = BandSearchDao::BAND_SEARCH_SELECT; $bandSearchQuery .= " AND B.BAND_ID IN (" . $bandIDQuery . ")\n\t\t\t\t\t\t\t\t\t\t\t\tORDER BY B.NAME ASC\n\t\t\t\t\t\t\t\t\t\t\t\tLIMIT :pagingAmount OFFSET :startingPoint"; $preparedStatement = BandSearchDao::getBandSearchPreparedStatement($bandSearchQuery, $searchParameters, $dbConnection); //Add paging parameters. $startingPoint = 0; $currentPage = $searchParameters->getVariable(SearchConstants::CURRENT_PAGE_ID); $pagingAmount = $searchParameters->getVariable(SearchConstants::PAGING_AMOUNT_ID); if ($currentPage > 1) { $startingPoint = ($currentPage - 1) * $pagingAmount; } $pagingAmount = (int) $pagingAmount; $startingPoint = (int) $startingPoint; $preparedStatement->bindParam(":pagingAmount", $pagingAmount, PDO::PARAM_INT); $preparedStatement->bindParam(":startingPoint", $startingPoint, PDO::PARAM_INT); $preparedStatement->execute(); while ($result = $preparedStatement->fetch()) { $band = BandSearchDao::extractBandSearchObject($result); if ($band !== null) { $band->setVariable(Band::GENRES, BandGenreDao::selectBandGenres($band->getVariable(Band::BAND_ID), $dbConnection)); $bandList[] = $band; } } $preparedStatement = null; } catch (Exception $ex) { echo "searchBands error: " . $ex->getMessage(); $bandList = null; } $preparedStatement = null; return $bandList; }