Edit report at https://bugs.php.net/bug.php?id=61843&edit=1
ID: 61843 User updated by: jdolieslager at gmail dot com Reported by: jdolieslager at gmail dot com Summary: mysqli fetch_object calls __set() before __construct() Status: Open Type: Bug -Package: mysql +Package: MySQLi related Operating System: Windows 7 x64 PHP Version: 5.3.10 Block user comment: N Private report: N New Comment: ** Changed to correct package category Previous Comments: ------------------------------------------------------------------------ [2012-04-24 19:45:14] jdolieslager at gmail dot com Description: ------------ I retrieve a record from the database and want to store into an object. This will be a dataobject that does basically validate the values. I noticed that the constructor will be called after the magic function __set has been called. This should be the other way around. =============== SYSTEM INFO ================== System Windows NT JESPER-LT 6.1 build 7601 (Windows 7 Ultimate Edition Service Pack 1) i586 Build Date Feb 2 2012 20:26:31 Compiler MSVC9 (Visual C++ 2008) Architecture x86 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--disable-isapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet" "--with-mcrypt=static" "--disable-static-analyze" =============================================== ================ MYSQLI ======================= MysqlI Support enabled Client API library version mysqlnd 5.0.8-dev - 20102224 - $Revision: 321634 $ Active Persistent Links 0 Inactive Persistent Links 0 Active Links 0 Directive Local Value Master Value mysqli.allow_local_infile On On mysqli.allow_persistent On On mysqli.default_host no value no value mysqli.default_port 3306 3306 mysqli.default_pw no value no value mysqli.default_socket no value no value mysqli.default_user no value no value mysqli.max_links Unlimited Unlimited mysqli.max_persistent Unlimited Unlimited mysqli.reconnect Off Off ===================================================== Beneath you'll find a basic example of the bug. The database structure I use for this example: CREATE TABLE `users` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `username` VARCHAR(50) NOT NULL, `password` VARCHAR(50) NOT NULL, `created` DATETIME NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `username` (`username`) ) Test script: --------------- class foo { function __construct() { echo '__construct() <br />'; } function __set($key, $value) { echo '__set() <br />'; } } $mysql = new mysqli('127.0.0.1', 'root', '', 'test'); $rs = $mysql->query('SELECT id, username, password FROM users'); $obj = $rs->fetch_object('foo'); Expected result: ---------------- __construct() __set() __set() __set() Actual result: -------------- __set() __set() __set() __construct() ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61843&edit=1