xref: /PHP-8.3/ext/pdo_mysql/tests/bug80808.phpt (revision b5a14e6c)
1--TEST--
2Bug #80808: PDO returns ZEROFILL integers without leading zeros
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12
13require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
14$pdo = MySQLPDOTest::factory();
15
16$pdo->exec('DROP TABLE IF EXISTS test');
17$pdo->exec('CREATE TABLE test (postcode INT(4) UNSIGNED ZEROFILL)');
18$pdo->exec('INSERT INTO test (postcode) VALUES (\'0800\')');
19
20$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
21var_dump($pdo->query('SELECT * FROM test')->fetchColumn(0));
22$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
23var_dump($pdo->query('SELECT * FROM test')->fetchColumn(0));
24
25?>
26--EXPECT--
27string(4) "0800"
28string(4) "0800"
29