Trying out PDO for the first time.
$dbh = new PDO(\"mysql:host=$hostname;dbname=animals\", $username, $password); $stmt = $dbh->query(\"SELECT * FROM ani
You can try this way:
$dbh = new PDO("mysql:host=$hostname;dbname=animals", $username, $password); $stmt = $dbh->query("SELECT * FROM animals"); $stmt->setFetchMode(PDO::FETCH_CLASS, animals::class); foreach($stmt as $animals) { echo $animals->name; }