Bug #64132 [Opn]: PDO/MySQL query fails when binding a float value with data type PDO::PARAM_INT
| From: | uw@php.net | Date: | Thu, 20 Mar 2014 16:09:58 +0000 |
| Subject: | Bug #64132 [Opn]: PDO/MySQL query fails when binding a float value with data type PDO::PARAM_INT | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184843@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64132&edit=1
ID: 64132
Updated by: uw@php.net
Reported by: ipernet at gmail dot com
Summary: PDO/MySQL query fails when binding a float value
with data type PDO::PARAM_INT
Status: Open
Type: Bug
-Package: PDO MySQL
+Package: PDO Core
Operating System: Slackware 13 x64
PHP Version: 5.4.11
Block user comment: N
Private report: N
New Comment:
PDO, not PDO MySQL bug: how can a driver be responsible for the core (ext/pdo)?
Previous Comments:
------------------------------------------------------------------------
[2013-06-16 03:07:47] kenji dot uui at gmail dot com
Disabling emulation of prepared statements makes no error.
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
------------------------------------------------------------------------
[2013-03-12 15:23:25] uw@php.net
Yet another PDO core bug that is not a MySQL bug...
PDO converts 1.25 to 1,25 as part of the statement emulation, puts 1,25 in the statement string and
your query becomes INSERT INTO (col) VALUES (1,25).
------------------------------------------------------------------------
[2013-02-11 09:51:29] ipernet at gmail dot com
Important note:
This only happens if the set locale use a comma as decimal separator.
Please add "setlocale(LC_ALL, 'fr_FR');" at the beginning of the test code to
reproduce.
This is still an unexpected behavior.
------------------------------------------------------------------------
[2013-02-02 15:14:14] ipernet at gmail dot com
Description:
------------
PHP:
5.4.11
PDO Client API version:
mysqlnd 5.0.10 - 20111026 - $Id: b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $
MySQL:
5.5.18-log
Using a PDO prepared statement to insert a new row, the query fails if a float
value is passed for a token and this token use PDO::PARAM_INT as data type.
Test script:
---------------
CREATE TABLE IF NOT EXISTS
test (
kms int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-------------------------------------------
$query = $dbh->prepare('INSERT INTO test(kms) VALUES(:kms)');
$query->bindValue(':kms', 1.25, PDO::PARAM_INT);
$query->execute();
var_dump($query->errorInfo());
Expected result:
----------------
- "1" should be inserted in the table
- Query should execute properly and do not lead to a SQL parsing error.
Actual result:
--------------
array(3) {
[0] =>
string(5) "21S01"
[1] =>
int(1136)
[2] =>
string(47) "Column count doesn't match value count at row 1"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64132&edit=1