コード例 #1
0
 /**
  * @param PDO $dbConn
  * @param int $episodeId
  * @param Episode $episodeObject
  */
 public static function getEpisodeAttributesFromDatabase($dbConn, $episodeId, $episodeObject)
 {
     $databaseResults = readFromDatabase::readFilteredColumnFromTable($dbConn, array(self::PROGRAM_COLUMN_NAME, self::PLAYLIST_COLUMN_NAME, self::PROGRAMMER_COLUMN_NAME, self::START_TIME_COLUMN_NAME, self::END_TIME_COLUMN_NAME), self::TABLE_NAME, array(self::ID_COLUMN_NAME), array($episodeId));
     $programId = $databaseResults[0][self::PROGRAM_COLUMN_NAME];
     $playlistId = $databaseResults[0][self::PLAYLIST_COLUMN_NAME];
     $programmerId = $databaseResults[0][self::PROGRAMMER_COLUMN_NAME];
     $episodeObject->setProgram(new Program($dbConn, $programId));
     $episodeObject->setPlaylist(new Playlist($dbConn, $playlistId));
     $episodeObject->setProgrammer(new Programmer($dbConn, $programmerId));
     $startTimeString = $databaseResults[0][self::START_TIME_COLUMN_NAME];
     $startDateTime = formatDateStringFromDatabase($startTimeString);
     $endTimeString = $databaseResults[0][self::END_TIME_COLUMN_NAME];
     $endDateTime = formatDateStringFromDatabase($endTimeString);
     $episodeObject->setStartTime($startDateTime);
     $episodeObject->setEndTime($endDateTime);
 }
コード例 #2
0
$episodeStartTime = $_POST['start_datetime'];
$episodeDuration = $_POST['episode_duration'];
$comment = $_POST['comment'];
session_start();
try {
    $db = connectToDatabase();
    $programmerId = 1;
    //TODO change programmerId once settled how programmers will be stored
    $playlistId = managePlaylistEntries::createNewPlaylist($db);
    $episodeStartTime = new DateTime($episodeStartTime, new DateTimeZone('America/Montreal'));
    $episode_end_time = clone $episodeStartTime;
    $episodeDurationMins = $episodeDuration * 60;
    $episodeDurationDateInterval = new DateInterval('PT' . $episodeDurationMins . 'M');
    $episode_end_time->add($episodeDurationDateInterval);
    $episodeObject = new Episode($db, null);
    $episodeObject->setPlaylist(new Playlist($db, $playlistId));
    $episodeObject->setProgram(new Program($db, $programId));
    $episodeObject->setProgrammer(new Programmer($db, $programmerId));
    $episodeObject->setStartTime($episodeStartTime);
    $episodeObject->setEndTime($episode_end_time);
    $episodeObject->setIsPrerecord($prerecord);
    $episodeObject->setPrerecordDate($prerecord_date);
    $episodeObject->setComment($comment);
    $episodeId = manageEpisodeEntries::saveNewEpisode($db, $episodeObject);
    $_SESSION["episodeId"] = $episodeId;
    error_log("session episode Id: " . $_SESSION["episodeId"]);
    header('Location: add-segments.php');
} catch (PDOException $e) {
    error_log('Error while saving an episode: ' . $e->getMessage());
    //TODO: error handling
}