ID: 43160 Updated by: [EMAIL PROTECTED] Reported By: riccardo dot bonciani at cinic dot it -Status: Open +Status: Bogus Bug Type: PDO related Operating System: Linux Gentoo PHP Version: 5.2.4 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . Previous Comments: ------------------------------------------------------------------------ [2007-10-31 11:49:39] riccardo dot bonciani at cinic dot it Description: ------------ By using FETCH_CLASS and __set overloading, __construct will be executed after populating object properties; Reproduce code: --------------- class Test { protected $prop; function __construct() { $this->prop['a'] = null; $this->prop['b'] = null; $this->prop['c'] = null; } function __set($name, $value) { $this->prop[$name] = $value; } } $query = "SELECT 1 AS a, 2 AS b, 3 AS c"; $sth = $objPDO->prepare($query); $sth->execute(); $result = $sth->fetchAll(PDO::FETCH_CLASS, 'Test'); var_dump($result); Expected result: ---------------- I expect array(1) { [0]=> object(Test)#8 (1) { ["prop:protected"]=> array(3) { ["a"]=> string(1) "1" ["b"]=> string(1) "2" ["c"]=> string(1) "3" } } } Actual result: -------------- array(1) { [0]=> object(Test)#8 (1) { ["prop:protected"]=> array(3) { ["a"]=> NULL ["b"]=> NULL ["c"]=> NULL } } } Try to comment __construct code and you'll obtain the right result. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43160&edit=1