|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67122 PDO::ATTR_EMULATE_PREPARES = false drops microseconds from timestamp
Submitted: 2014-04-23 22:16 UTC Modified: 2018-06-15 05:34 UTC
Avg. Score:4.8 ± 0.6
Reproduced:29 of 29 (100.0%)
Same Version:5 (17.2%)
Same OS:6 (20.7%)
From: russellbarnhart at gmail dot com Assigned:
Status: Duplicate Package: PDO MySQL
PHP Version: 5.5.11 OS: Ubuntu 12.04 & 14.04
Private report: No CVE-ID: None
 [2014-04-23 22:16 UTC] russellbarnhart at gmail dot com
This is only relevant on the newer versions of mysql/mariaDB that support microsecond precision on timestamp columns.

minimum Mysql version: 5.6.4
minimum MariaDB version: 5.3

When the PDO attribute ATTR_EMULATE_PREPARES is false, any microseconds are dropped from timestamp columns.

I'm using:

MariaDB v10.0.10: mysql  Ver 15.1 Distrib 10.0.10-MariaDB, for debian-linux-gnu (x86_64) using readline 5.1

PHP (cli) (built: Apr 23 2014 12:23:08)
(also tested on PHP 5.5.9-1ubuntu4 (cli) (built: Apr  9 2014 17:11:57))

mysqlnd v5.0.11-dev

Test script:

Expected result:
2014-04-23 08:45:36.022588
2014-04-23 08:45:36.022588

Actual result:
2014-04-23 08:45:36.022588
2014-04-23 08:45:36


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-16 06:42 UTC] webmaster at etherframegames dot com
Any updates on this? I can confirm that it still exists as of 7.1.5
 [2018-04-10 12:25 UTC] labs at strongholdmedia dot eu
Can anybody elaborate if this is really a problem with PDO itself, or, rather, is the cause the underlying mysqlnd (that is still 5.0.12-dev from 2015)?
 [2018-04-12 10:04 UTC] labs at strongholdmedia dot eu
This is indeed a problem with PDO; when using mysqli, the issue is not apparent.
 [2018-05-16 01:28 UTC] ell at cybercog dot su
I've found possible solution:
 [2018-05-29 07:09 UTC] labs at strongholdmedia dot eu
Thanks for the follow up, it was very useful.

It is apparent that, regardless I did not get the error with mysqli, it is not a bug with PDO per se but instead the prepared statement handler in mysqlnd.
(That shall mean it would have had happened with mysqli as well had I used prepared statements.)

I try and open a bug with them then.

(No wonder I did not find anything in the PDO sources. :P)
 [2018-05-30 10:58 UTC] info at strongholdmedia dot eu
Created a new, more appropriate bug here

and commented a lot there.

The solution proposed here does not work as it has been written for a fixed precision of 6, whilst MySQL supports any precision between 0-6.

I also created a proper fix and sent a pull request that did not make any tests fail.
See here:

I am unsure when it will be merged and into which release though (even though it is 100% backwards compatible).
 [2018-06-15 05:34 UTC]
-Status: Open +Status: Duplicate
 [2018-06-15 05:34 UTC]
See bug #76386.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 04:01:28 2024 UTC