php.net |  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: 2021-01-12 19:40 UTC
Votes:1
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: Duplicate Package: MySQLi related
PHP Version: 7.0.26 OS: Red Hat 6.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: judge2005 at gmail dot com
New email:
PHP Version: OS:

 

 [2017-12-21 17:38 UTC] judge2005 at gmail dot com
Description:
------------
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:
---------------
CREATE TABLE test (
  datetime_col datetime(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

commit;

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

commit;

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

while($stmt->fetch()) {
        var_dump($result);
}
?>


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"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-12 19:40 UTC] dharman@php.net
-Status: Open +Status: Duplicate
 [2021-01-12 19:40 UTC] dharman@php.net
Duplicate of Bug #76386	Prepared Statement formatter truncates fractional seconds from date/time column

Fixed in PHP 7.3
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 16:01:27 2024 UTC