From: craig dot marvelley at boxuk dot com
Operating system: Windows/Linux
PHP version: 5.3.0beta1
PHP Bug Type: MySQL related
Bug description: mysql_fetch_field ignores zero offset
Description:
------------
When calling mysql_fetch_field(), it seems that in PHP 5.3 the offset
parameter, when set to 0, is being ignored - the current pointer
offset is returned instead. According to the manual, that should only
happen if the field offset is not supplied.
I've tested this in PHP 4 and 5.2 but the above behaviour isn't
repeated.
Reproduce code:
---------------
// connect to database, etc...
$sql = "SELECT * FROM someTable";
$result = mysql_query($sql);
// set the internal pointer to the second field...
mysql_field_seek($result, 1);
// ... but we'll start at the first field (i.e. ignore the pointer)
$i = 0;
while($i<mysql_num_fields($result))
{
$meta=mysql_fetch_field($result,$i);
echo $i . "." . $meta->name . "<br />";
$i++;
}
Expected result:
----------------
For a table with columns like this:
column1 | column2 | column3
I'd expect to see
0. column1
1. column2
2. column3
(This happens in PHP < 5.3beta1)
Actual result:
--------------
I get this:
0. column2
1. column2
2. column3
--
Edit bug report at http://bugs.php.net/?id=47438&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47438&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47438&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47438&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47438&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47438&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47438&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47438&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47438&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47438&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47438&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47438&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47438&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47438&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47438&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47438&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47438&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47438&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47438&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47438&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47438&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47438&r=mysqlcfg