ID:               42689
 User updated by:  evangun2001 at yahoo dot fr
 Reported By:      evangun2001 at yahoo dot fr
 Status:           Assigned
 Bug Type:         MySQLi related
 Operating System: windows
 PHP Version:      5CVS-2007-09-17 (CVS)
 Assigned To:      andrey
 New Comment:

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.


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

[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

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

[2007-09-17 22:26:39] evangun2001 at yahoo dot fr

Description:
------------
Hello,

As you can see in the code below, binding to $value['id'] will not work
because $value is a variable generated by the foreach loop. Using a
dimensional variable as a parameter causes no bugs outside a foreach
loop, so I'm pretty sure it really is a bug.

$arr = array(array('id' => 1));
$stmt = $dbh -> prepare('SELECT member_login FROM members WHERE
member_id = ?;');
$stmt -> bind_param('i', $value['id']);

foreach($arr as $value){
        
        echo $value['id'];      //this will output 1 as expected
        
        $stmt -> execute();
        $stmt -> bind_result($login);
        while($stmt -> fetch()){
                echo $login;    //this will output nothing
        }
}

Reproduce code:
---------------
The code I've given in description pretty much says it all !
For a quick and global understanding of the situation, I've also put a
summary of what works, what does not work, and the workaround I've been
using so far. Check it here :

http://trombiaudencia2.free.fr/bug.txt

Actual result:
--------------
Just to let you know, in my application, the real bind_param line
looked like :

$stmt -> bind_param('si', $_POST['members'][$value['id']]['login'],
$value['id']);

and in that case, php told me :
Fatal error: Only variables can be passed by reference in E:\Program
Files\EasyPHP\www\create_quiz_ajaxrequests.php on line 368

which is due to the second parameter, the first one does not create any
warning at all. Strange, because you'll see that in the simplified
example I've given above, no error message is displayed at all.

I use loops all the time so to me, it's reeaaally a down side for
MySQLi not to be able to bind parameters. I have been using PDO for a
while and heard MySQLi had better performances, but this kinda cools me
down :( Maybe I'll wait a bit until this bug is fixed before I migrate
to MySQLi.

Thank you very much !!
Evangun


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


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

Reply via email to