Bug #74006 [Fbk->NoF]: fractional seconds support missing
Edit report at https://bugs.php.net/bug.php?id=74006&edit=1
ID: 74006
Updated by: php-bugs@lists.php.net
Reported by: smithlmk at gmail dot com
Summary: fractional seconds support missing
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: PDO MySQL
Operating System: windows 7
PHP Version: 7
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2020-01-03 18:30:13] cmb@php.net
I cannot reproduce this with PHP 7.2.26 or later. Can you still
reproduce with any of the actively supported PHP versions[1]? If
so, do you use any non-default configuration? Also, which
database version do you use?
[1] <https://www.php.net/supported-versions.php>
------------------------------------------------------------------------
[2017-04-21 19:03:59] robert dot reinhard at bukwild dot com
Yes, I am experiencing in 7.0.13
------------------------------------------------------------------------
[2017-02-01 13:30:48] andrew dot nester dot dev at gmail dot com
I was trying to reproduce your issue on latest 7.0 and 7.1 versions - looks like it's working,
could you please retest it on latest versions?
------------------------------------------------------------------------
[2017-01-27 10:38:30] smithlmk at gmail dot com
Updated PHP version, as this bug goes all the way up to PHP 7.
------------------------------------------------------------------------
[2017-01-27 09:12:38] smithlmk at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=74006&edit=1
Thread (6 messages)