public function GetLatestEpisode() { $query = self::db()->Prepare("\n SELECT nzbid FROM downloads\n WHERE show_id = ?\n ORDER BY season DESC, episode DESC\n LIMIT 1\n "); $query->Execute(array($this->show_id)); $data = $query->FetchObject(); if (!$data) { return NULL; } $episode = new Episode(array('nzbid' => $data->nzbid)); $episode->FetchInto(); return $episode; }