Bug #75719 [Opn->Dup]: mysqli_bin_result drops datetime precision
| From: | dharman@php.net | Date: | Tue, 12 Jan 2021 19:40:36 +0000 |
| Subject: | Bug #75719 [Opn->Dup]: mysqli_bin_result drops datetime precision | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231518@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75719&edit=1
ID: 75719
Updated by: dharman@php.net
Reported by: judge2005 at gmail dot com
Summary: mysqli_bin_result drops datetime precision
-Status: Open
+Status: Duplicate
Type: Bug
Package: MySQLi related
Operating System: Red Hat 6.3
PHP Version: 7.0.26
Block user comment: N
Private report: N
New Comment:
Duplicate of Bug #76386 Prepared Statement formatter truncates fractional seconds from date/time
column
Fixed in PHP 7.3
Previous Comments:
------------------------------------------------------------------------
[2017-12-21 17:38:33] 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"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75719&edit=1