#48487 [Opn]: fetch_object calls __set before constructor

From: Date: Tue, 25 Aug 2009 17:14:43 +0000
Subject: #48487 [Opn]: fetch_object calls __set before constructor
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-141508@lists.php.net to get a copy of this message
 ID:               48487
 User updated by:  joel at purerave dot com
 Reported By:      joel at purerave dot com
 Status:           Open
 Bug Type:         MySQLi related
 Operating System: win2k sp4
 PHP Version:      5.2.9
 New Comment:

No response yet?


Previous Comments:
------------------------------------------------------------------------

[2009-06-06 20:33:40] joel at purerave dot com

Description:
------------
mysqli_fetch_object with custom class calls __set() before constructor.

Reproduce code:
---------------
<?php
$mysqli = new mysqli("localhost", "root", "root", "test");
class myData {
	function __construct($param) {
		echo 'creating'.PHP_EOL;
	}
	function __set($name, $value) {
		$this->{$name} = $value;
		echo 'setting'.PHP_EOL;
	}
}

$sql = "SELECT id FROM test LIMIT 1";
$result = $mysqli->query($sql);
while ($obj = $result->fetch_object('myData', array('data'))) {
}

Expected result:
----------------
creating
setting


Actual result:
--------------
setting
creating



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48487&edit=1



Thread (7 messages)

« previous php.bugs (#141508) next »