|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-06-21 23:53 UTC] rodolfo at rodsoft dot org
[2004-08-07 11:01 UTC] georg@php.net
[2004-08-07 11:24 UTC] helly@php.net
[2004-08-07 11:26 UTC] helly@php.net
[2004-08-07 13:06 UTC] georg@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 01:00:01 2025 UTC |
Description: ------------ If you pass to mysqli_bind_result a member variable of an object that will be cloned and modified multiple times, each modification happens in all cloned objects, as if they weren't cloned copies, but a single copy of the object. Reproduce code: --------------- <? /* Say you have a database called 'test' with one table called 'test' that has one column called 'a' */ $db = new mysqli('localhost'); $db->select_db('test'); $stmt = $db->prepare('SELECT a FROM test'); $stmt->execute(); $result = new stdclass; // Comment the next line to have the 'right' behaviour $stmt->bind_result($result->a); for($i = 0; $i<10; ++$i) { $result->a = $i; $results[] = clone $result; } foreach($results as $result) echo $result->a,"\n"; $db->close(); ?> Expected result: ---------------- 0 1 2 3 4 5 6 7 8 9 Actual result: -------------- 9 9 9 9 9 9 9 9 9 9