From: rodolfo at rodsoft dot org
Operating system: linux 2.6.7
PHP version: 5.0.0RC3
PHP Bug Type: *Database Functions
Bug description: mysqli_bind_result doesn't work with cloned objects
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
--
Edit bug report at http://bugs.php.net/?id=28870&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28870&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28870&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28870&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28870&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28870&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28870&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28870&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28870&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28870&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28870&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28870&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28870&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28870&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28870&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28870&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28870&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28870&r=float