Answer the question
In order to leave comments, you need to log in
How to convert fetch_class to a string in PDO to the required type for the class?
$stmt = $pdo->prepare('SELECT * FROM user LIMIT 10');
$stmt->execute();
$sub = $stmt->fetchAll(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, User::class);
// User
private int $id;
private string $email;
private \DateTimeInterface $created_at;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question