Closed vlaaadislav closed 4 years ago
@vlaaadislav thanks for this. can you please provide some snippets on how to use this PR?
PHP:
class Person
{
public function __construct()
{
dd($this);
}
}
$pdo = DB::getPdo();
$stmt = $pdo->prepare("SELECT * FROM people");
$result = $stmt->execute();
$stmt->fetchAll(PDO::FETCH_CLASS, 'Person');
What I expect dump inside constructor will print:
Person{
+"id": "1"
+"name": "One"
}
But now it works as $stmt->fetchAll(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Person'):
Person{}
PDO::FETCH_CLASS: returns a new instance of the requested class, mapping the columns of the result set to named properties in the class, and calling the constructor afterwards, unless PDO::FETCH_PROPS_LATE is also given.
As I understood, constructor should be called after properties mapping.