php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51163 fetch_field variants manual is wrong - they dont provide default value def
Submitted: 2010-02-27 04:55 UTC Modified: 2010-08-18 14:36 UTC
From: berniev at bje dot com dot au Assigned: abedford (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.1 OS: ubuntu 9
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: berniev at bje dot com dot au
New email:
PHP Version: OS:

 

 [2010-02-27 04:55 UTC] berniev at bje dot com dot au
Description:
------------
The manuals for PHP all show mysql_fetch_field (s) (and mysqli) provide the table default value, WHICH THEY DO NOT!

The manuals appear to be blatantly wrong. 
Interestingly the examples conveniently leave out def values.

This may also apply to autoinc and primary key flags?

The only reference to this I could find anywhere is a note from shoresofnowhere at gmail dot com 26-Aug-2009 10:50 after hours of searching.

Please Please update the manuals!! (or fix php !)


Reproduce code:
---------------
---
From manual page: http://www.php.net/mysqli-result.fetch-field-direct
---



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-27 23:29 UTC] niel dot archer at blueyonder dot co dot uk
This appears to be a bug, not a documentation problem.  I just tried this on PHP 5.3 using the MySQLi extension.

$finfo = $result->fetch_field();
echo $finfo->def;

Prints an empty string, it does not produce an error for an invalid property.
 [2010-03-01 15:07 UTC] berniev at bje dot com dot au
You are correct in that fetch_field doesn't crash but it always produces empty default column data.

Googling shows this is a common problem. Workaround is to use mysql SHOW COLUMNS FROM .. but this is an extra step.
shoresofnowhere at gmail dot com 26-Aug-2009 10:50  in http://au2.php.net/mysqli-result.fetch-field-direct suggests it will never produce a result by design and gives what appears a reasonable explanation.

I tried examining sources but am not clever enough yet to figure it out. Maybe someone can point me in the right direction.

For the benefit of all us noobs please clarify if this is a bug or design.

In any event it appears to have been like this for a while and I think this should be reflected in the documentation. Seems to be quite a few of us wasting a lot of time looking for explanation.
 [2010-08-18 14:12 UTC] abedford@php.net
Automatic comment from SVN on behalf of abedford
Revision: http://svn.php.net/viewvc/?view=revision&revision=302439
Log: Fixed doc bug #51163. Removed references to def field, as no meaningful value is returned for it.
 [2010-08-18 14:36 UTC] abedford@php.net
-Status: Assigned +Status: Closed
 [2010-08-18 14:36 UTC] abedford@php.net
I've removed references to the def field as no meaningful value is returned for 
that field in both mysql and mysqli. If developers later decide to add support for 
this field I can add details back in.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 20:00:02 2026 UTC