Bug #55536 [NEW]: MySQLi fetch corrupting bound variables
| From: | taopixdev at yahoo dot co dot uk | Date: | Tue, 30 Aug 2011 10:31:05 +0000 |
| Subject: | Bug #55536 [NEW]: MySQLi fetch corrupting bound variables | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-163136@lists.php.net to get a copy of this message | ||
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