entry)) { die('No video entries found in the RSS feed.'); } $pdo = db(); $stmt = $pdo->prepare("INSERT IGNORE INTO youtube_videos (youtube_id, title, thumbnail_url, published_at) VALUES (:youtube_id, :title, :thumbnail_url, :published_at)"); foreach ($xml->entry as $entry) { $media = $entry->children('media', true); $yt = $entry->children('yt', true); $video_id = (string)$yt->videoId; $title = (string)$media->group->title; $thumbnail_url = (string)$media->group->thumbnail->attributes()->url; $published_at = new DateTime((string)$entry->published); $stmt->execute([ ':youtube_id' => $video_id, ':title' => $title, ':thumbnail_url' => $thumbnail_url, ':published_at' => $published_at->format('Y-m-d H:i:s') ]); } echo "YouTube videos have been successfully imported.";