|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-01-12 19:40 UTC] dharman@php.net
-Status: Open
+Status: Duplicate
[2021-01-12 19:40 UTC] dharman@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 05:00:01 2025 UTC |
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"