ID:               42689
 Updated by:       [EMAIL PROTECTED]
 Reported By:      evangun2001 at yahoo dot fr
-Status:           Assigned
+Status:           Bogus
 Bug Type:         MySQLi related
 Operating System: windows
 PHP Version:      5CVS-2007-09-17 (CVS)
 Assigned To:      andrey
 New Comment:

Bogus issue. In the test case you have this 

$stmt -> bind_param('i', $value['id']);
foreach($arr as $value){
        echo $value['id'];      //this will output 1 as expected

Which is equivalent to the following example :

[EMAIL PROTECTED]:~/dev/vanilla/php5_3> ./php -r '
$value["id"] = 2;
var_dump($value);
$arr = array(1, 2, 3);
var_dump($arr);
foreach ($arr as $value) {
  var_dump($value);
}
var_dump($value);'
array(1) {
  ["id"]=>
  int(2)
}
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
int(1)
int(2)
int(3)
int(3)
----------------

What you do is you overwrite $value, the fetch works in the background
and fetches in what $value['id'] used to be (just a NULL zval). However,
your foreach uses $value for iterating the values, thus you get 1 for
the first (and last) iteration.


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

[2008-02-05 17:25:28] evangun2001 at yahoo dot fr

About the 2 last comments : please read the details I gave in the link
I provided. You'll understand something goes wrong indeed, the function
works half the way it should. Call it a bug or not, as you wish.

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

[2008-02-05 01:21:27] cool_lim_lp at yahoo dot com dot sg

there is a problem with your code.

you're binding to a $value array that does not exist outside the
foreach loop. so in reality, you're binding to  a NULL value. and of
course, when you executed the statement, no result will match, hence
output nothing.

it 's not a bug.

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

[2007-10-26 12:21:16] c dot glaab at web dot de

Hi there,

i don't think it's a bug.

you're foreach creates a new array ($value), so the reference from
bind_result will be lost.

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

[2007-09-19 14:37:22] evangun2001 at yahoo dot fr

Hello,
I've run the tests on 5.2.0, 5.2.4 and CVS, MySQL 5.0.27.
Same results each time.
By the way, just to let you know, the CVS version seems unstable with
my full MySQLi script (more complex than what I've shown you), whereas
it works with 5.2.4.
Thanks

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

[2007-09-19 11:04:09] uwendel at mysql dot com

Can you tell me what MySQL and PHP versions you're using? Is it really
a CVS version/development snapshot that you're using?

Thanks!
Ulf

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/42689

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

Reply via email to