Olá....estou praticando PHP web tentando desenvolver uma plataforma de filmes, porém nao estou conseguindo retornar meu objecto com os dados. Estou usando o xampp como server e o phpadmin para meu data base. Será que alguém consegue me dar uma luz do que estou fazendo de errado? segue o meu index.php. Por enquanto estou somente tentando retornar meu objeto usando o var_dump() e isso me retorna object(PDO)#1 (0) { }
<?php
$pdo = new PDO('mysql:host=localhost;dbname=hey_movies', "root", '');
var_dump($pdo);
?>
index.php
<?php
require "src/connect-db.php";
require "src/Model/Movie.php";
$sql1 = "SELECT * from movies";
$statement = $pdo->query($sql1);
$cardsMovie = $statement->fetchAll(PDO::FETCH_ASSOC);
$dataMovie = array_map(function ($movie) {
return new Movie($movie['id'], $movie['movieTitle'], $movie['movieDescription'],
$movie['movieReleaseYear'], $movie['movieLanguage'], $movie['movieGenere'],
$movie['movieClassification'], $movie['movieMainActors'],
$movie['movieDirector'], $movie['movieSourceInformation'],
$movie['streamingService'], $movie['imageUrl'], $movie['imageTwoUrl']);
}, $cardsMovie);
var_dump($dataMovie);
exit();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style/reset.css">
<title>Hey Movies</title>
<!-- BOOTSTRAP - ICON -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<!-- BOOTSTRAP -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="./style/style.css">
</head>
<body>
<main class="container-fluid border bg-dark mb-5">
<!-- CARDS SECTIONS -->
<section class="container-right-section">
<div class="container">
<div class="row">
<!-- MAIN BAR -->
<div class="col-8">
<div class="trending__product">
<!-- TRANDING NOW & VIEW ALL TEXT -->
<div class="row">
<div class="col-8">
<div class="section-title">
<h4 class="card-title">TRENDING NOW</h4>
</div>
</div>
<div class="col-4">
<div class="btn__all">
<a href="#" class="primary-btn card-title">VIEW ALL<span class="arrow_right"></span></a>
</div>
</div>
</div>
<!-- MOVIE ROW -->
<div class="row">
<!-- MOVIE ELEMENT -->
<?php foreach ($cardsMovie as $cards) : ?>
<div class="col-lg-4 col-md-6 col-sm-6">
<div class="product__item">
<div class="product__item__pic set-bg" data-setbg="<?= "img/" . $cards['image_url'] ?>">
<div class="container-img">
<img src="<?= $cards['image_url'] ?>" alt="" width="200px" height="280px">
</div>
<div class="ep"><?= $cards['Streaming_service'] ?></div>
<div class="comment"><i class="fa fa-comments"></i><?= $cards['Movies_language'] ?></div>
<div class="view"><i class="fa fa-eye"></i><?= $cards['Movies_Releaseyear'] ?></div>
</div>
<div class="product__item__text">
<ul>
<li><?= $cards['Movies_Genre'] ?></li>
<li><?= $cards['Movies_Classification'] ?></li>
</ul>
<h5><a href="#"><?= $cards['Movies_title'] ?></a></h5>
</div>
</div>
</div>
<?php endforeach; ?>