Bug #74006 [NEW]: fractional seconds support missing
| From: | smithlmk at gmail dot com | Date: | Fri, 27 Jan 2017 09:12:43 +0000 |
| Subject: | Bug #74006 [NEW]: fractional seconds support missing | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-206974@lists.php.net to get a copy of this message | ||
From: smithlmk at gmail dot com
Operating system: windows 7
PHP version: 5.6.30
Package: PDO MySQL
Bug Type: Bug
Bug description:fractional seconds support missing
Description:
------------
Fractional seconds are supported in MySQL DateTime(x) field types.
Writing such fields with fractional seconds via PDO into MySQL database
is fully supported, however reading such fields directly via PDO won't
return fractional seconds. A clumsy workaround is to wrap every DateTime
field with a CONCAT function as shown in below test.
Test script:
---------------
(1) Create this table in MySQL:
CREATE TABLE
test (
id int(11) NOT NULL,
dt datetime(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(2) Connect db via PDO and do this:
$pdo->query("REPLACE INTO test (id, dt) VALUES (1, '2017-1-1
12:30:00.123')");
$a = $pdo->query("SELECT dt FROM test WHERE id = '1'")->fetch();
$b = $pdo->query("SELECT CONCAT(dt) AS dt FROM test WHERE id =
'1'")->fetch();
var_dump($a, $b);
Expected result:
----------------
array(1) {
'dt' =>
string(23) "2017-01-01 12:30:00.123"
}
array(1) {
'dt' =>
string(23) "2017-01-01 12:30:00.123"
}
Actual result:
--------------
array(1) {
'dt' =>
string(19) "2017-01-01 12:30:00"
}
array(1) {
'dt' =>
string(23) "2017-01-01 12:30:00.123"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=74006&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74006&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74006&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74006&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74006&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74006&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74006&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74006&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74006&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74006&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74006&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74006&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74006&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74006&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74006&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74006&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74006&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74006&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74006&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74006&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74006&r=mysqlcfg