From:             jgauld at blueyonder dot co dot uk
Operating system: WinXP
PHP version:      5.2.5
PHP Bug Type:     PDO related
Bug description:  PDO quotes integers in prepared statement

Description:
------------
When executing a prepared statement with bound values, any integer types
are seemingly treated as strings and quoted in the final SQL statement (SQL
statements taken from MySQL server log).

I realise I've not used the 'data_type' parameter for the ->bindValue()
method, but according to the PHP manual I shouldn't need to ...

"Explicit data type for the parameter using the PDO::PARAM_* constants.
Defaults to PHP native type."

So the PHP native type in the shown case is an integer - equivalent to
PDO::PARAM_INT, yes?

Reproduce code:
---------------
CREATE TABLE my_db.my_table (
  id int(10) unsigned NOT NULL auto_increment,
  PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

<?php
$DB = new PDO('mysql:dbname=my_db;host=localhost', 'user', 'pass');
$stmt = $DB->prepare('select * from my_table where id>?');
$stmt->bindValue(1, 13);
$stmt->execute();
?>

or

<?php
$DB = new PDO('mysql:dbname=my_db;host=localhost', 'user', 'pass');
$stmt = $DB->prepare('select * from my_table where id>?');
$stmt->execute(array(13));
?>

Expected result:
----------------
select * from my_table where id>13

Actual result:
--------------
select * from my_table where id>'13'

-- 
Edit bug report at http://bugs.php.net/?id=44639&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44639&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44639&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44639&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44639&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44639&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44639&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44639&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44639&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44639&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44639&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44639&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44639&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44639&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44639&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44639&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44639&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44639&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44639&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44639&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44639&r=mysqlcfg

Reply via email to