php-src/ext/pdo_mysql/tests/bug80808.phpt
Nikita Popov 3a867b9827 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).
2021-03-02 10:59:34 +01:00

28 lines
812 B
PHP

--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"