php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68573 No mention that fetch_fields()'s output depends on client charset
Submitted: 2014-12-09 09:21 UTC Modified: 2015-09-03 23:31 UTC
From: sebastianzartner at gmail dot com Assigned: philip (profile)
Status: Closed Package: MySQLi related
PHP Version: 5.6.3 OS:
Private report: No CVE-ID: None
 [2014-12-09 09:21 UTC] sebastianzartner at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/mysqli-result.fetch-fields
---

The return values for mysqli_result::fetch_fields are vaguely defined.
There is no mention that 'length' and 'charsetnr' depend on the default client character set, which can be changed via mysqli::set_charset.

This leads to great confusions[1] as people expect 'length' to reflect the length they set for the column.

E.g. a column defined as varchar(10) will result in 'length' being 30 and 'charsetnr' being 33 if the client charset is set to 'utf8'.

[1] http://stackoverflow.com/q/10430406/432681


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-03 23:31 UTC] philip@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: philip
 [2015-09-03 23:31 UTC] philip@php.net
Thank you for the detailed bug report, it is much appreciated. A fix has been committed to SVN and it will show up online shortly. The example was expanded to include the 'length' and use two different character sets (latin1 and utf8), and also the length description was expanded to explain bytes vs characters using utf8 and latin1 as examples. Again, thank you for the bug report.
 [2015-09-03 23:32 UTC] philip@php.net
Automatic comment from SVN on behalf of philip
Revision: http://svn.php.net/viewvc/?view=revision&revision=337742
Log: Fixed PHP Bug #68573 by expanding the examples to use multiple character sets, and mentioning what 'length' means.
 [2015-09-04 15:16 UTC] sebastianzartner at gmail dot com
Great! Thank you!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 18:02:40 2024 UTC