|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75719 mysqli_bin_result drops datetime precision
Submitted: 2017-12-21 17:38 UTC Modified: -
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: judge2005 at gmail dot com Assigned:
Status: Open Package: MySQLi related
PHP Version: 7.0.26 OS: Red Hat 6.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
16 + 17 = ?
Subscribe to this entry?

 [2017-12-21 17:38 UTC] judge2005 at gmail dot com
If the mysql bind result mechanism is used to retrieve results from a column that is declared with sub-second precision, the extra precision is lost. This only happens with mysqlnd, not libmysqlclient, and it doesn't happen if fetch_assoc() is called.

Test script:
  datetime_col datetime(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


insert into test values ('2017-12-05 01:02:03.456');
insert into test values ('2017-12-05 07:08:09.000');


$conn = new mysqli($servername, $username, $password, $dbname, $port);
$sql = "SELECT datetime_col from test";
$stmt = $conn->prepare($sql);

while($stmt->fetch()) {

Expected result:
string(23) "2017-12-05 01:02:03.456"
string(23) "2017-12-05 07:08:09.000"

Actual result:
string(19) "2017-12-05 01:02:03"
string(19) "2017-12-05 07:08:09"


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Feb 22 13:01:25 2020 UTC