|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-04-01 07:48 UTC] crocodile2u at yandex dot ru
[2008-11-06 10:48 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
Description: ------------ when you call PDOStatement::fetch() with the fetch mode PDO::FETCH_CLASS PDO will create FooClass' instance. And in the creation process PDO (or script engine?) calls __set() method before calling FooClass' __construct(). Reproduce code: --------------- class FooClass { public function __construct($param) { echo "FooClass::constructor\n"; } protected function &__set($name, $value) { echo "FooClass::__set()\n"; } } $pdo = new PDO($dsn, ...); $stmt = $pdo->prepare('SELECT * FROM ...'); $stmt->setFetchMode(PDO::FETCH_CLASS, FooClass, array('bar')); $fooInst = $stmt->fetch(); Expected result: ---------------- The script should output strings in the following order: 1. FooClass::constructor 2. FooClass::__set() Actual result: -------------- 1. FooClass::__set() 2. FooClass::constructor