diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-02 10:58:35 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-02 10:59:34 +0100 |
commit | 3a867b982755501b514d19418086972a0cc693e7 (patch) | |
tree | b659eff4fa0fb3029ceed0e78dc52f9cd20672db /ext/pdo_mysql | |
parent | c28751c69c9e2f923dd923fee5e1d4a3c970308a (diff) | |
download | php-git-3a867b982755501b514d19418086972a0cc693e7.tar.gz |
Fixed bug #80808
If the ZEROFILL flag is set for a field, do not convert it into
an integer (text protocol) or convert it explicitly into a padded
string (binary protocol).
Diffstat (limited to 'ext/pdo_mysql')
-rw-r--r-- | ext/pdo_mysql/tests/bug80808.phpt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ext/pdo_mysql/tests/bug80808.phpt b/ext/pdo_mysql/tests/bug80808.phpt new file mode 100644 index 0000000000..364b559a4c --- /dev/null +++ b/ext/pdo_mysql/tests/bug80808.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #80808: PDO returns ZEROFILL integers without leading zeros +--SKIPIF-- +<?php +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); +MySQLPDOTest::skip(); +?> +--FILE-- +<?php + +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); +$pdo = MySQLPDOTest::factory(); + +$pdo->exec('DROP TABLE IF EXISTS test'); +$pdo->exec('CREATE TABLE test (postcode INT(4) UNSIGNED ZEROFILL)'); +$pdo->exec('INSERT INTO test (postcode) VALUES (\'0800\')'); + +$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); +var_dump($pdo->query('SELECT * FROM test')->fetchColumn(0)); +$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); +var_dump($pdo->query('SELECT * FROM test')->fetchColumn(0)); + +?> +--EXPECT-- +string(4) "0800" +string(4) "0800" |