Bug #77954 [NEW]: Binding value as PDO::PARAM_INT has different behaviour in PHP 7.2

From: Date: Wed, 01 May 2019 08:59:43 +0000
Subject: Bug #77954 [NEW]: Binding value as PDO::PARAM_INT has different behaviour in PHP 7.2
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220661@lists.php.net to get a copy of this message
From: f dot bosch at genkgo dot nl Operating system: Ubuntu PHP version: 7.2.17 Package: PDO MySQL Bug Type: Bug Bug description:Binding value as PDO::PARAM_INT has different behaviour in PHP 7.2 Description: ------------ When binding a value against a MySQL PDO statement, the behaviour between PHP 7.1 and PHP 7.2 differs. When you bind a value as integer while passing a float, this was no problem with PHP7.1. However, it became a problem in PHP7.2. The problem is when executing the following. It inserts 0.5 in PHP7.1, and 0 in PHP7.2. I have tested this against MariaDB (10.1 and 10.2), not against MySQL. Another person also found difference in behaviour: https://stackoverflow.com/questions/54413798/pdoparam-int-behaviour-in-php-7-1-php-7-2. $stmt = $pdo->prepare('INSERT INTO tbl (val) VALUES (?)'); $stmt->bindValue(1, 0.5, PDO::PARAM_INT); See also this pull request in the Laravel Framework for this behaviour change: https://github.com/laravel/framework/pull/28379. Test script: --------------- <?php $pdo = new PDO('mysql:dbname=floattest;host=127.0.0.1', 'root', ''); $create = $pdo->prepare('CREATE TABLE IF NOT EXISTS tbl (val DECIMAL(9,2))'); $create->execute(); $del = $pdo->prepare('DELETE FROM tbl'); $del->execute(); $ins = $pdo->prepare('INSERT INTO tbl (val) VALUES (?)'); $ins->bindValue(1, 0.5, PDO::PARAM_INT); $ins->execute(); $sel = $pdo->prepare('SELECT * FROM tbl'); $sel->execute(); var_dump($sel->fetchColumn(0)); Expected result: ---------------- 0.5 Actual result: -------------- 0 -- Edit bug report at https://bugs.php.net/bug.php?id=77954&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77954&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77954&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77954&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77954&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77954&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77954&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77954&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77954&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77954&r=support Expected behavior: https://bugs.php.net/fix.php?id=77954&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77954&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77954&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77954&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77954&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77954&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77954&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77954&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77954&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77954&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77954&r=mysqlcfg

« previous php.bugs (#220661) next »