|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-04-26 18:30 UTC] martin at bangaroo dot net
[2009-04-27 20:47 UTC] martin at bangaroo dot net
[2009-09-22 17:57 UTC] sjoerd@php.net
[2009-10-26 22:10 UTC] hradtke@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 20:00:01 2025 UTC |
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