|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-11-19 02:38 UTC] danielc at analysisandsolutions dot com
Description:
------------
Running PHP 5.4 compiled from svn earlier today. The "length" values from fetch_field() are multiplied by 3 when building mysqli against mysqlnd. The values are correct when building against libmysql.
Test script:
---------------
$db = new mysqli(null, $_ENV['MYSQL_TEST_USER'],
$_ENV['MYSQL_TEST_PASSWD'], $_ENV['MYSQL_TEST_DB'],
null, $_ENV['MYSQL_TEST_SOCKET']);
$result = $db->query("CREATE TEMPORARY TABLE phptest_fk (
txt TEXT NULL,
chr2 CHAR(2) default 'df' NOT NULL,
chr10 CHAR(10) default 'df' NOT NULL)");
if (!$result) {
echo "OOPS: $db->error\n";
exit(1);
}
$result = $db->query("INSERT INTO phptest_fk VALUES ('One', 'c1')");
$result = $db->query("SELECT * FROM phptest_fk");
$info = $result->fetch_field();
echo "$info->name $info->length\n";
$info = $result->fetch_field();
echo "$info->name $info->length\n";
$info = $result->fetch_field();
echo "$info->name $info->length\n";
Expected result:
----------------
txt 65535
chr2 2
chr10 10
Actual result:
--------------
txt 196605
chr2 6
chr10 30
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 16:00:02 2025 UTC |
I think this might be down to what encoding the connection is using. The length in bytes of a mysql utf8 CHAR(2) field is 6. If you issue a $db->query('SET NAMES latin1'); before the CREATE TABLE then you should get the results you are expecting.