From: damir21 at hotmail dot com
Operating system: Win 7
PHP version: 5.2.12
PHP Bug Type: MySQL related
Bug description: mysql_list_fields deprecated
Description:
------------
I am trying to fetch a complete mySQL table schema and I found a great
function in between the comments for the mysql_fetch_field function.
On the documentation page for mysql_fetch_field function you are using
$result handle like this
$result = mysql_query('select * from table');
....
$meta = mysql_fetch_field($result, $i);
The problem is, that the $meta->def value is ALWAYS empty.
The problem is also noted here:
http://www.phpdig.net/ref/rn41re784.html
Te only way it works is if I use a deprecated function
(mysql_list_fields()) like this:
$result = mysql_list_fields ($dbname, $tablename);
....
$meta = mysql_fetch_field($result, $i);
in this case the $meta->def is populated correctly!
Please make it clear in the documentations OR make it work correctly with
you preffered method:
$result = mysql_query('select * from table');
best regards
Reproduce code:
---------------
---
>From manual page: function.mysql_fetch_field#Examples
---
<?php
mysql_connect("127.0.0.1","nobody","");
$result = mysql_query('select * from table');
//...
$meta = mysql_fetch_field($result, 0);
echo $meta->def;
?>
Expected result:
----------------
0
Actual result:
--------------
null
--
Edit bug report at http://bugs.php.net/?id=50685&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=50685&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=50685&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=50685&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=50685&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=50685&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=50685&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=50685&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=50685&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=50685&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=50685&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=50685&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=50685&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=50685&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=50685&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50685&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50685&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=50685&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=50685&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=50685&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=50685&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=50685&r=mysqlcfg