From:             
Operating system: 
PHP version:      Irrelevant
Package:          MySQLi related
Bug Type:         Bug
Bug description:MySQLi fetch corrupting bound variables

Description:
------------
I have tested this in different versions of PHP and it seems to be a bug
from version 5.3.0 onwards.

It seems that from PHP version 5.3.0 onwards that when a MySQL select
statement returns zero rows the bind result variable is being overwritten
and set to a null value. 

In the example attached to this post I initialize a variable called
$recordID and set it to 0;

In versions of PHP prior to version 5.3.0 after the fetch has ran the
$recordID would still be set to 0 when zero rows are returned. However from
versions 5.3.0 onwards the $recordID variable is overwritten and set to
null.




Test script:
---------------
<?php

$pID = 0;
$recordID = 0;

if ($stmt = $dbObj->prepare('SELECT `id`, `name` FROM MYTABLE WHERE id =
?)
{
    if ($stmt->bind_param('i', $pID))
    {
          if ($stmt->bind_result($recordID, $name)
          {
               if ($stmt->execute())
               {
                    $stmt->fetch();
               }
          }
    }
}

?>

Expected result:
----------------
In versions of PHP prior to version 5.3.0 after the fetch has ran the
$recordID would still be set to 0 when zero rows are returned. 



Actual result:
--------------
>From versions 5.3.0 onwards the $recordID variable is overwritten and set
to null.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=55536&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=55536&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=55536&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=55536&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=55536&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=55536&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=55536&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=55536&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=55536&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=55536&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=55536&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=55536&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=55536&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=55536&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=55536&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=55536&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55536&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=55536&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=55536&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=55536&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=55536&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=55536&r=mysqlcfg

Reply via email to