From:             martin at bangaroo dot net
Operating system: Gentoo Linux
PHP version:      5.2.1
PHP Bug Type:     PDO related
Bug description:  Executing prepared statement changes type of bound parameters 
to string

Description:
------------
Executing a prepared statement changes the type of bound parameters 
to string (Tested only with pgsql driver).

This bite me when I wanted to execute an insert statement only when 
the double value to be inserted actually changed, NULL being a 
possible value. Unfortunatly, comparing the new value with the old 
value with the !== operator didn't work, because the type-change 
made the test always evaluate to TRUE.


Reproduce code:
---------------
<?php
  $db = new PDO("pgsql:host=localhost dbname=test user=dummy");

  $db->query("CREATE TABLE test_table ( val REAL )");
  $qry = $db->prepare("INSERT INTO test_table VALUES (:val)");
  $qry->bindParam(":val",$bound_val);

  $bound_val = 5.2;
  echo "Type before execute(): ".gettype($bound_val)."\n";
  $qry->execute();
  echo "Type after execute(): ".gettype($bound_val)."\n";

  $db->query("DROP TABLE test");
?>

Expected result:
----------------
Type before execute(): double
Type after execute(): double


Actual result:
--------------
Type before execute(): double
Type after execute(): string


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

Reply via email to