diff --git a/app/src/Domain/Repository/Episode/EpisodeRepository.php b/app/src/Domain/Repository/Episode/EpisodeRepository.php index 2536a13..ebc1da0 100644 --- a/app/src/Domain/Repository/Episode/EpisodeRepository.php +++ b/app/src/Domain/Repository/Episode/EpisodeRepository.php @@ -16,6 +16,9 @@ class EpisodeRepository implements EpisodeRepositoryInterface private DatabaseHandlerInterface $db ) { } + /** + * @param array The query results from the database + */ protected function getEpisodeFromResults(array $results): Episode { $results['createdAt'] = new DateTimeImmutable($results['created_at']); @@ -54,8 +57,8 @@ class EpisodeRepository implements EpisodeRepositoryInterface public function create(Episode $episode): Episode { $query = "INSERT INTO episodes ( - title, link, length, description, serialNumber, - explicit, publishedDate, episodeType + title, link, length, description, serial_number, + explicit, published_date, episode_type ) VALUE ( :title, :link, :length, :description, :serialNumber, :explicit, :publishedDate, :episodeType @@ -76,6 +79,33 @@ class EpisodeRepository implements EpisodeRepositoryInterface return $episode; } + public function update(Episode $episode): bool + { + $query = "UPDATE episodes + SET title = :title, + link = :link, + length = :length, + description = :description, + serial_number = :serialNumber, + explicit = :explicit, + published_date = :publishedDate, + episode_type = :episodeType + WHERE id = :id"; + + $result = $this->db->execute($query, [ + ':title' => $episode->getTitle(), + ':link' => $episode->getLink(), + ':length' => $episode->getLength(), + ':description' => $episode->getDescription(), + ':serialNumber' => $episode->getSerialNumber(), + ':explicit' => $episode->isExplicit(), + ':publishedDate' => $episode->getPublishedDate(), + ':episode_type' => $episode->getEpisodeType(), + ]); + + return $result; + } + /** * @TODO Implement a plan for deleting */