setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $posts = [ [ 'title' => 'The Timeless Elegance of Hand-Knotted Carpets', 'slug' => 'timeless-elegance-hand-knotted-carpets', 'content' => 'Hand-knotted carpets are more than just floor coverings; they are works of art, imbued with history and craftsmanship. In this post, we explore the intricate process of creating these masterpieces and why they remain a symbol of luxury and timeless elegance in any interior.', 'author' => 'Jane Doe', 'image_url' => '/assets/images/blog1.jpg', 'seo_title' => 'The Timeless Elegance of Hand-Knotted Carpets', 'seo_meta_description' => 'Discover the art and history behind hand-knotted luxury carpets and why they are a timeless addition to any home.' ], [ 'title' => 'How to Choose the Perfect Carpet for Your Space', 'slug' => 'how-to-choose-perfect-carpet', 'content' => 'Choosing the right carpet can transform a room. This guide provides expert tips on selecting the perfect carpet based on material, color, and foot traffic to match your lifestyle and decor. From plush wool to durable synthetics, find the ideal fit for your home.', 'author' => 'John Smith', 'image_url' => '/assets/images/blog2.jpg', 'seo_title' => 'A Guide to Choosing the Perfect Luxury Carpet', 'seo_meta_description' => 'Our expert guide helps you select the perfect luxury carpet for your home, considering material, color, and use.' ] ]; $stmt = $pdo->prepare( "INSERT INTO posts (title, slug, content, author, image_url, seo_title, seo_meta_description, published_at) VALUES (:title, :slug, :content, :author, :image_url, :seo_title, :seo_meta_description, NOW()) ON DUPLICATE KEY UPDATE title=VALUES(title), content=VALUES(content)" ); foreach ($posts as $post) { $stmt->execute($post); } echo "Successfully seeded the posts table with " . count($posts) . " articles.\n"; } catch (PDOException $e) { die("Seeding failed: " . $e->getMessage() . "\n"); }