Bug #48487 [Com]: fetch_object calls __set before constructor
Edit report at http://bugs.php.net/bug.php?id=48487&edit=1
ID: 48487
Comment by: vadimx at gmail dot com
Reported by: joel at purerave dot com
Summary: fetch_object calls __set before constructor
Status: Closed
Type: Bug
Package: MySQLi related
Operating System: win2k sp4
PHP Version: 5.2.9
New Comment:
In mysql_fetch_object the same bug.
Previous Comments:
------------------------------------------------------------------------
[2010-01-04 10:31:36] uw@php.net
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Fixed with http://news.php.net/php.cvs/61460
------------------------------------------------------------------------
[2009-11-06 16:29:19] caferrari at gmail dot com
Help!.. i am having this issue with php 5.2.10 on Ubuntu 9.10 and Debian
5... and its evil!... my solution:
class Exemplo {
public function __construct($id=0, $nome='', $sigla=''){
if (isset($this->id)) return; //Ugly solution!!! help!
$this->id = $id;
$this->nome = $nome;
$this->sigla = $sigla;
}
}
------------------------------------------------------------------------
[2009-08-25 17:14:42] joel at purerave dot com
No response yet?
------------------------------------------------------------------------
[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/bug.php?id=48487&edit=1
Thread (7 messages)