ID: 50685 Updated by: j...@php.net Reported By: damir21 at hotmail dot com -Status: Open +Status: Bogus Bug Type: MySQL related Operating System: Win 7 PHP Version: 5.2.12 New Comment:
RTFM: "This function is deprecated. It is preferable to use mysql_query() to issue a SQL SHOW COLUMNS FROM table [LIKE 'name'] statement instead. " And the correct manual page is here: http://php.net/mysql_list_fields Previous Comments: ------------------------------------------------------------------------ [2010-01-07 14:19:54] damir21 at hotmail dot com 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 this bug report at http://bugs.php.net/?id=50685&edit=1