/** * @param PDO $dbConn * * @param int $segmentId * * @param Segment $segmentObject * */ public static function getSegmentAttributesFromDatabase($dbConn, $segmentId, $segmentObject) { $databaseResult = readFromDatabase::readFilteredColumnFromTable($dbConn, null, self::TABLE_NAME, array(self::ID_COLUMN_NAME), array($segmentId)); $segmentName = $databaseResult[0][self::SEGMENT_NAME_COLUMN_NAME]; $segmentObject->setName($segmentName); $segmentAlbum = $databaseResult[0][self::ALBUM_COLUMN_NAME]; $segmentObject->setAlbum($segmentAlbum); $segmentAuthor = $databaseResult[0][self::AUTHOR_COLUMN_NAME]; $segmentObject->setAuthor($segmentAuthor); $segmentCategory = $databaseResult[0][self::CATEGORY_COLUMN_NAME]; $segmentObject->setCategory($segmentCategory); $segmentDuration = $databaseResult[0][self::DURATION_COLUMN_NAME]; $segmentObject->setDuration($segmentDuration); $segmentCanCon = $databaseResult[0][self::CAN_CON_COLUMN_NAME]; $segmentObject->setIsCanCon($segmentCanCon); $segmentNewRelease = $databaseResult[0][self::NEW_RELEASE_COLUMN_NAME]; $segmentObject->setIsNewRelease($segmentNewRelease); $segmentFrenchVocalMusic = $databaseResult[0][self::FRENCH_VOCAL_MUSIC_COLUMN_NAME]; $segmentObject->setIsFrenchVocalMusic($segmentFrenchVocalMusic); $dbStartTimeString = $databaseResult[0][self::START_TIME_COLUMN_NAME]; $startDateTime = formatDateStringFromDatabase($dbStartTimeString); $segmentObject->setStartTime($startDateTime); }
$editSegment = isset($_POST['is_existing_segment']); $segmentId = $_POST['segment_id']; if (!isset($episodeId) || $episodeId <= 0) { outputErrorResponse("Invalid episode ID"); } try { $db = connectToDatabase(); $episode = new Episode($db, $episodeId); $episodeStartDateTime = $episode->getStartTime(); $segmentTime = addDateToSegmentStartTime($episodeStartDateTime, $segmentTime); $playlistId = $episode->getPlaylistId(); $segment = new Segment($db, $segmentId); $segment->setCategory($category); $segment->setPlaylistId($playlistId); $segment->setDuration(null); $segment->setStartTime($segmentTime); switch ($category) { case 2: case 3: $segment->setName($name); $segment->setAuthor($author); $segment->setAlbum($album); $segment->setCategory($category); $segment->setIsCanCon($canCon); $segment->setIsNewRelease($newRelease); $segment->setIsFrenchVocalMusic($frenchVocalMusic); $segment->setAdNumber(null); break; case 5: $segment->setName(null); $segment->setAuthor(null);