|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77954 Binding value as PDO::PARAM_INT has different behaviour in PHP 7.2
Submitted: 2019-05-01 08:59 UTC Modified: 2019-05-01 09:14 UTC
Avg. Score:4.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: f dot bosch at genkgo dot nl Assigned:
Status: Open Package: PDO MySQL
PHP Version: 7.2.17 OS: Ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-05-01 08:59 UTC] f dot bosch at genkgo dot nl
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:

$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:

Test script:
$pdo = new PDO('mysql:dbname=floattest;host=', 'root', '');

$create = $pdo->prepare('CREATE TABLE IF NOT EXISTS tbl (val DECIMAL(9,2))');

$del = $pdo->prepare('DELETE FROM tbl');

$ins = $pdo->prepare('INSERT INTO tbl (val) VALUES (?)');
$ins->bindValue(1, 0.5, PDO::PARAM_INT);

$sel = $pdo->prepare('SELECT * FROM tbl');

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-01 09:02 UTC]
-Status: Open +Status: Feedback
 [2019-05-01 09:02 UTC]
Why do you think the previous behavior was correct? It seems right to me that if an integer binding is requested it should be bound as an integer.
 [2019-05-01 09:10 UTC] f dot bosch at genkgo dot nl
-Status: Feedback +Status: Open
 [2019-05-01 09:10 UTC] f dot bosch at genkgo dot nl
You are right. I totally agree that the previous behaviour was not correct. Since I could not find any reason why the behaviour change was there, no backward-incompatibility notice in this regard, I was wondering if this is intensional. This could affect quite some people, especially those using the Laravel framework and/or only its database component.

If you no idea, please just close the report.
 [2019-05-01 09:14 UTC]
-Type: Bug +Type: Documentation Problem
 [2019-05-01 09:14 UTC]
This should be due to bug #73234 /

Changing this to a doc problem as this probably should indeed be mentioned in the upgrading guide.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jun 27 00:01:25 2019 UTC