Bug #75719 [NEW]: mysqli_bin_result drops datetime precision

From: Date: Thu, 21 Dec 2017 17:38:35 +0000
Subject: Bug #75719 [NEW]: mysqli_bin_result drops datetime precision
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213223@lists.php.net to get a copy of this message
From: judge2005 at gmail dot com Operating system: Red Hat 6.3 PHP version: 7.0.26 Package: MySQLi related Bug Type: Bug Bug description:mysqli_bin_result drops datetime precision 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 bug report at https://bugs.php.net/bug.php?id=75719&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75719&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75719&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75719&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75719&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75719&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75719&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75719&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75719&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75719&r=support Expected behavior: https://bugs.php.net/fix.php?id=75719&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75719&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75719&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75719&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75719&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75719&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75719&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75719&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75719&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75719&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75719&r=mysqlcfg

« previous php.bugs (#213223) next »