From 3a867b982755501b514d19418086972a0cc693e7 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 2 Mar 2021 10:58:35 +0100 Subject: 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). --- ext/pdo_mysql/tests/bug80808.phpt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ext/pdo_mysql/tests/bug80808.phpt (limited to 'ext/pdo_mysql') 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-- + +--FILE-- +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" -- cgit v1.2.1